搜索插件、代码仓与 APP 分类

youtube_api 封面
插件详情v1.0.4

youtube_api

YouTubeAPI 是一个直接与 YouTube 服务器交互的插件。支持搜索视频和播放列表。

近 30 天下载
143
喜欢数
85
Pub 分数
100

安装插件

flutter pub add youtube_api

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

YouTubeAPI 是一个 Flutter 插件,可直接与 YouTube 服务器交互,使开发者能够搜索视频和播放列表。该插件设计简洁高效,可无缝集成到 Flutter 应用中,无需复杂设置即可访问 YouTube 的核心搜索功能。该插件由 nstack.in 维护,并托管在 GitHub 上,便于开源贡献。它支持 Android 和 iOS 平台,但元数据中未列出具体的平台详情。

适合场景

  • 将 YouTube 视频搜索集成到应用中
  • 通过编程方式获取播放列表数据
  • 构建媒体发现功能
  • 创建视频推荐系统
  • 启用用户驱动的内容探索

主要特点

  • 直接YouTube服务器通信
  • 视频和播放列表搜索功能
  • 与 Flutter 的简单集成
  • GitHub 上的开源代码库
  • 跨平台支持(Android/iOS)

适合对象

  • 开发媒体丰富的 Flutter 应用的开发者
  • 需要 YouTube 内容发现的应用
  • 需要实时视频搜索的项目
  • 开源视频工具贡献者
  • 教育或娱乐应用开发者

使用建议

  • 需要互联网连接以进行API调用
  • 取决于YouTube公开API的可用性
  • 生产使用可能需要API密钥配置
  • 仅限搜索功能(无播放控制)
  • 元数据中未提供官方文档

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

YouTube API Client (youtube_api_client)

Forked (all restructured and improved) from youtube_api

A Flutter plugin for fetching interacting with YouTube Server to fetch data using API. Supports iOS and Android.

Features:

  • Search Video, Playlist, Channel on YouTube (query by keywords or by ID)
  • Get Trending Videos based on region code.

Usage

To use this plugin, add youtube_api_client as a dependency in your pubspec.yaml file.

Complete Example Code

Example
static String key = "YOUR_API_KEY";
final youtube = YoutubeApi(_key);
List<ApiResult> result = [];

Search for videos, channels and playlists

String query = "Flutter";
result = await youtube.search(query);
// data which are available in result is typed as in the example shown below

By default the search options are like the following:

SearchOptions options = const SearchOptions(
      type: ResultType.values,
      order: Order.relevance,
      videoDuration: VideoDuration.any,
    )

But you can customize them changing the parameter options. For example, if you want to get only results for channels, you can specify like so:

SearchOptions(type: ResultType.channel)

To get Trending videos in your Country-

regionCode='YOUR_COUNTRY_REGION_CODE(apha-2)';
result = await youtube.getTrends(regionCode);
//make sure you assign alpha-2 region code

To get results by id use searchVideosById, searchChannelsById, and searchPlaylistsById.

result = await youtube.searchVideosById(idList);

You can find your Country Region Code here

By default, it retrieves only the "snippet" data, which has enough information for most of the cases.

For example the snippet for a video contains:

  1. title (String)
  2. description (String)
  3. publish date (DateTime)
  4. channel ID (String)
  5. channel title (String)
  6. thumbnails (Map<ThumbnailResolution, Thumbnail> - custom classes)
  7. video category (Category - enum)
  8. tags (List)
  9. default language (String)
  10. defaultAudioLanguage (String)
  11. live broadcast content (LiveBroadcastContent - enum)

If you need more information from the API, you can add other parts in the query. For now it has only the part "snippet" and "content details" (containing: duration, dimension, definition, caption, licensed content, and projection). The original API has lots more of information, so you are welcome to help implementing those making pull requests.

Motivation

The original package seems to be abandoned. I improved a lot its code, making it more typed, and added more features.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。