youtube_data_v3 0.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

youtube_data_v3 #

pub package

Package contains functions to access Youtube Data API V3 via the API key.

The package uses Api's with parameters having less quota's.

Features #

  • Channel & videos from channel id.

Usage #

To use this plugin add 'youtube_data_v3' as a dependency in pubspec.yaml file.

Example #


import 'package:youtube_data_v3/youtube_data_v3.dart';
import 'package:youtube_data_v3/youtube_channel.dart';
import 'package:youtube_data_v3/youtube_video.dart';

final ytApi = YoutubeV3();
ytApi.init("API KEY");
YtChannel channel = await ytApi.getChannelFromId("CHANNEL ID");
//Get title of channel
print(channel.title);
//Get the channel uploads(All the videos in a channel) id
print(channel.uploadsId);
//Get the channel Description
print(channel.description);
//Get the channel url
print(channel.customUrl);
//Get the channel thumbnail
print(channel.thumbnailDetails);
ThumbnailDetails channelTumbnail = channel.thumbnailDetails;
//Get the channel publised date
DateTime chPubTime = channel.publishedAt;
//Get google youtube api channel
Channel gApi = channel.gApiChannel;

//Get the first page of videos from channel. Optional: Max num of Results, Optional: get duration of video also (defaults to false)
List<YtVideo> videoList = await channel.getPageOfVideos(numResults: 10, showDuration: true);

//Shows the next page of videos from the last time a call was made to getPageOfVideos
videoList = await channel.getPageOfVideos(numResults: 10, showDuration: true, showNextPage: true);
//gives previous page of videos from the last time a call was made to getPageOfVideos
videoList = await channel.getPageOfVideos(numResults: 10, showDuration: true, showPrevPage: true);

//YtVideo
//Get title of video
print(videoList[0].title);
//Position of video in the list of videos received
print(videoList[0].position);
//Get duration of video
print(videoList[0].duration);//Showed as 10:41 or 1:10:41
//Get description
print(videoList[0].description);
//Get Video id
print(videoList[0].videoId);
//Get thumbnail
ThumbnailDetails videoThumbnail = videoList[0].thumbnailDetails;
// Get published date
DateTime vidPubTime = videoList[0].publishedAt;
//Get channel id
print(videoList[0].channelId);
//Get playlist id of the video
print(videoList[0].id);
//Get google youtube api video item
PlaylistItem videoItem = videoList[0].videoItem;

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1] - 3.6.2019

  • Initial Release

[0.0.1+1] - 4.6.2019

  • Updated readme and added example (No change in public API)

example/main.dart

import 'package:youtube_data_v3/youtube_data_v3.dart';
import 'package:youtube_data_v3/youtube_channel.dart';
import 'package:youtube_data_v3/youtube_video.dart';

main(List<String> arguments) async {

  const String API_KEY = "";// API key from Google console
  const String CHANNEL_ID = "";// Channel Id of the youtube channel to fetch videos from

  final ytApi = YoutubeV3();
  ytApi.init(API_KEY);
  YtChannel channel = await ytApi.getChannelFromId(CHANNEL_ID);
  print(channel.title);
  print(channel.uploadsId);

  List<YtVideo> videoList = await channel.getPageOfVideos(numResults: 10, showDuration: true);
  print(videoList.length);

  //title of the video
  print(videoList[0].title);
  //position of the video in the list of videos from the page received
  print(videoList[0].position);
  //duration of the video (only present when show duration is set to true)
  print(videoList[0].duration);

  //Url of the thumbnail of the video
  print(videoList[0].thumbnailDetails.default_.url);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  youtube_data_v3: ^0.0.1+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:youtube_data_v3/youtube_data_v3.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

52 out of 52 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/youtube_channel.dart.

Run flutter format to format lib/youtube_channel.dart.

Format lib/youtube_data_v3.dart.

Run flutter format to format lib/youtube_data_v3.dart.

Format lib/youtube_video.dart.

Run flutter format to format lib/youtube_video.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (googleapis).

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
googleapis ^0.53.0 0.53.0 0.54.0
googleapis_auth ^0.2.7 0.2.10
http ^0.12.0+2 0.12.0+2
Transitive dependencies
_discoveryapis_commons 0.1.9
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
flutter_test