From 1fda8f7d6a7db156f2d79f22db422bbb870e233d Mon Sep 17 00:00:00 2001 From: Hexah Date: Fri, 5 Jun 2020 20:14:22 +0200 Subject: [PATCH] Prepare for beta release --- README.md | 11 +---- example/video_download.dart | 2 +- lib/src/videos/streams/stream_manifest.dart | 10 ++--- pubspec.yaml | 4 +- tools/t2.dart | 5 --- tools/test.dart | 48 --------------------- 6 files changed, 10 insertions(+), 70 deletions(-) delete mode 100644 tools/t2.dart delete mode 100644 tools/test.dart diff --git a/README.md b/README.md index a8b3545..e1c9735 100644 --- a/README.md +++ b/README.md @@ -18,21 +18,16 @@ This doesn't require an API key and has no usage quotas. - All model extend `Equatable` to easily perform equality checks - Download Stream -## Features not implemented - -- Adaptive streams ## Differences from YoutubeExplode - The entry point is `YoutubeExplode`, not `YoutubeClient`. -- The `MediaStreamInfoSet` class has a `videoDetails` class which contains info about the video metadata (to avoid making several api calls). -- The `ClosedCaption` has a `end` getter to get when a closed captions ends being displayed. ## Install Add the dependency to the pubspec.yaml (Check for the latest version) ```yaml -youtube_explode_dart: ^0.0.9 +youtube_explode_dart: ^1.0.0-beta ``` Import the library @@ -44,8 +39,6 @@ import 'package:youtube_explode_dart/youtube_explode_dart.dart'; To start using the API you need to initialize the `YoutubeExplode` class (which will create a new http client), and get (for example) the video id of the video you'd want to retrieve information, which usually is the `v` parameter. ```dart -var id = YoutubeExplode.parseVideoId('https://www.youtube.com/watch?v=OpQFFLBMEPI'); // Returns `OpQFFLBMEPI` - var yt = YoutubeExplode(); ``` @@ -53,7 +46,7 @@ var yt = YoutubeExplode(); The [Video][Video] class contains info about the video such as the video title, the duration or the search keywords. ```dart -var video = yt.getVideo(id); // Returns a Video instance. +var video = yt.video.get(id); // Returns a Video instance. ``` ## Get video mediaStream diff --git a/example/video_download.dart b/example/video_download.dart index 215931f..1a5e2d0 100644 --- a/example/video_download.dart +++ b/example/video_download.dart @@ -32,7 +32,7 @@ Future download(String id) async { // Get the video manifest. var manifest = await yt.videos.streamsClient.getManifest(id); - var streams = manifest.getAudioOnly(); + var streams = manifest.audioOnly; // Get the last audio track (the one with the highest bitrate). var audio = streams.last; diff --git a/lib/src/videos/streams/stream_manifest.dart b/lib/src/videos/streams/stream_manifest.dart index 4275c5e..d82fb37 100644 --- a/lib/src/videos/streams/stream_manifest.dart +++ b/lib/src/videos/streams/stream_manifest.dart @@ -16,22 +16,22 @@ class StreamManifest { /// Gets streams that contain audio /// (which includes muxed and audio-only streams). - Iterable getAudio() => streams.whereType(); + Iterable get audio => streams.whereType(); /// Gets streams that contain video /// (which includes muxed and video-only streams). - Iterable getVideo() => streams.whereType(); + Iterable get video => streams.whereType(); /// Gets muxed streams (contain both audio and video). /// Note that muxed streams are limited in quality and don't go beyond 720p30. - Iterable getMuxed() => streams.whereType(); + Iterable get muxed => streams.whereType(); /// Gets audio-only streams (no video). - Iterable getAudioOnly() => + Iterable get audioOnly => streams.whereType(); /// Gets video-only streams (no audio). /// These streams have the widest range of qualities available. - Iterable getVideoOnly() => + Iterable get videoOnly => streams.whereType(); } diff --git a/pubspec.yaml b/pubspec.yaml index cc646cb..a9586f7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: youtube_explode_dart -description: A port in dart of the youtube explode library. Supports several API functions. -version: 0.0.17 +description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key. +version: 1.0.0-beta homepage: https://github.com/Hexer10/youtube_explode_dart environment: diff --git a/tools/t2.dart b/tools/t2.dart deleted file mode 100644 index 015281f..0000000 --- a/tools/t2.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:youtube_explode_dart/src/channels/channels.dart'; - -void main() { - var u = Username('youtube.com/user/ProZD'); -} \ No newline at end of file diff --git a/tools/test.dart b/tools/test.dart deleted file mode 100644 index c805911..0000000 --- a/tools/test.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:http/http.dart' as http; -import 'package:youtube_explode_dart/youtube_explode_dart.dart'; - -var regex = r''' -(?(DEFINE) -# Note that everything is atomic, JSON does not need backtracking if it's valid -# and this prevents catastrophic backtracking -(?(?>\s*(?&object)\s*|\s*(?&array)\s*)) -(?(?>\{\s*(?>(?&pair)(?>\s*,\s*(?&pair))*)?\s*\})) -(?(?>(?&STRING)\s*:\s*(?&value))) -(?(?>\[\s*(?>(?&value)(?>\s*,\s*(?&value))*)?\s*\])) -(?(?>true|false|null|(?&STRING)|(?&NUMBER)|(?&object)|(?&array))) -(?(?>"(?>\\(?>["\\\/bfnrt]|u[a-fA-F0-9]{4})|[^"\\\0-\x1F\x7F]+)*")) -(?(?>-?(?>0|[1-9][0-9]*)(?>\.[0-9]+)?(?>[eE][+-]?[0-9]+)?)) -) -\A(?&json)\z -'''; - -var sep = 'ytplayer.config = '; - -Future main() async { - var yt = YoutubeExplode(); - var m = await yt.videos.streamsClient.getManifest(VideoId('9bZkp7q19f0')); - var s = await yt.videos.streamsClient.get(m.streams.first).toList(); - print(s); - yt.close(); - print('Done!'); -} - -String matchJson(String str) { - var bracketCount = 0; - for (var i = 0; i < str.length; i++) { - if (str[i] == '{') { - bracketCount++; - } else if (str[i] == '}') { - bracketCount--; - } else if (str[i] == ';') { - if (bracketCount == 0) { - return str.substring(0, i); - } - } - } - throw FormatException('Failed to extract json'); -} - -var data = r''' - -''';