youtube_extractor 1.0.3

YouTube Extractor #


YouTube Extractor is a library for Dart (and Flutter) that provides an interface to resolve and download YouTube video and audio streams. This library is being primarily developed to provide YouTube support for the mobile SoundByte apps.

YouTube Extractor is a port of YouTubeExplode for Dart (minus some extra features that were not needed).

Features #

  • Download YouTube audio and video streams.
  • Access the YouTube live steaming url.

Usage #

YouTube Extractor has a single entry point, the YouTubeExtractor class. See the example folder for more information.

Get an audio stream #

import 'package:youtube_extractor/youtube_extractor.dart';

var extractor = YouTubeExtractor();

main() async {
  // Get the stream info for the passed video
  var streamInfo = await extractor.getMediaStreamsAsync('a1ExYqrBJio');
  // Print the audio stream url
  print('Audio URL: ${}');

1.0.3 #

  • Fixed crash caused by YouTube API change thanks to @EddieJeong.

1.0.2 #

  • Fixed crash caused by YouTube API change thanks to @davidgalarza.

1.0.1 #

  • Fixed crash caused by YouTube API change.

1.0.0 #

  • Library now follows standard practices.
  • Reuse http client for all requests.
  • Rename main method.
  • Added Dash support.
  • Fixed misc bugs.

0.1.1 #

  • Import dart:async.
  • Fix typos.
  • Run dartfmt.

0.1.0 #

  • Initial beta release.


// This file shows a demostration on how to use the library.
import 'package:youtube_extractor/youtube_extractor.dart';

var extractor = YouTubeExtractor();

main() async {
  // Get and print the audio info for the passed video (music video)
  var musicVideoInfo = await extractor.getMediaStreamsAsync('52nfjRzIaj8');
  print('Music Video Audio URL: ${}');

  // Get and print the audio info for the passed video (music)
  var audioInfo = await extractor.getMediaStreamsAsync('a1ExYqrBJio');
  print('Audio URL: ${}');

  // Get and print the video info for the passed video (ltt)
  var videoInfo = await extractor.getMediaStreamsAsync('j3YQAoN2wGM');
  print('Video URL: ${}');

  // Get information for a live YouTube video
  // 'mSQIX_G3TjU' Live video is currently not available
  // var livestream = await extractor.getMediaStreamsAsync('mSQIX_G3TjU');
  // print('Livestream URL: ${livestream.hlsLiveStreamUrl}');

  // Another test
  var previousBrokenStream = await extractor.getMediaStreamsAsync('m7Bc3pLyij0');
  print('Previous Broken Stream URL: ${}');

  var previousBrokenStream2 = await extractor.getMediaStreamsAsync('Soa3gO7tL-c');
  print('Previous Broken Stream 2 URL: ${}');

  var previousBrokenStream3 = await extractor.getMediaStreamsAsync('YQHsXMglC9A');
  print('Previous Broken Stream 3 URL: ${}');

Use this package as a library

1. Depend on it

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

  youtube_extractor: ^1.0.3

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_extractor/youtube_extractor.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:youtube_extractor/youtube_extractor.dart.

Health suggestions

Fix lib/src/internal/parsers/player_source_parser.dart. (-1.49 points)

Analysis of lib/src/internal/parsers/player_source_parser.dart reported 3 hints:

line 39 col 12: Don't explicitly initialize variables to null.

line 40 col 12: Don't explicitly initialize variables to null.

line 41 col 12: Don't explicitly initialize variables to null.

Format lib/youtube_extractor.dart.

Run dartfmt to format lib/youtube_extractor.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+2
xml ^3.2.3 3.5.0
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http_parser 3.1.3
meta 1.1.7
path 1.6.2
pedantic 1.8.0+1
petitparser 2.4.0
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6