Ready for 1.0.0 stable

This commit is contained in:
Hexah 2020-06-07 23:08:49 +02:00
parent d174130c6b
commit 202946d929
4 changed files with 10 additions and 33 deletions

View File

@ -16,8 +16,6 @@ This doesn't require an API key and has no usage quotas.
- Provides static methods to validate IDs and to parse IDs from URLs - Provides static methods to validate IDs and to parse IDs from URLs
- No need for an API key and no usage quotas - No need for an API key and no usage quotas
- All model extend `Equatable` to easily perform equality checks - All model extend `Equatable` to easily perform equality checks
- Download Stream
## Differences from YoutubeExplode ## Differences from YoutubeExplode
@ -27,7 +25,7 @@ This doesn't require an API key and has no usage quotas.
Add the dependency to the pubspec.yaml (Check for the latest version) Add the dependency to the pubspec.yaml (Check for the latest version)
```yaml ```yaml
youtube_explode_dart: ^1.0.0-beta youtube_explode_dart: ^1.0.0
``` ```
Import the library Import the library
@ -49,7 +47,7 @@ The [Video][Video] class contains info about the video such as the video title,
var video = yt.video.get(id); // Returns a Video instance. var video = yt.video.get(id); // Returns a Video instance.
``` ```
## Get video mediaStream ## Get video streams
The Manifest contains the audio, video and muxed streams of the video. Each of the streams provides an url which can be used to download a video with a get request (See [example][VidExample]). The Manifest contains the audio, video and muxed streams of the video. Each of the streams provides an url which can be used to download a video with a get request (See [example][VidExample]).
```dart ```dart
var manifest = yt.videos.streamsClient.getManifest(videoId); var manifest = yt.videos.streamsClient.getManifest(videoId);
@ -62,29 +60,13 @@ var video = manifest.video; // List of `VideoSteamInfo` sorted by video quality.
Be aware, the muxed streams don't hold the best quality, to achieve so, you'd need to merge the audio and video streams. Be aware, the muxed streams don't hold the best quality, to achieve so, you'd need to merge the audio and video streams.
## Closed Captions - Not yet implemented ## Closed Captions
To get the video closed caption it is need to query before the caption track infos, which can be used to retrieve the closed caption. To get the video closed caption it is need to query before the caption track infos, which can be used to retrieve the closed caption.
```dart ```dart
var trackInfos = await yt.getVideoClosedCaptionTrackInfos(id); // Get the caption track infos var trackInfos = await yt.videos.closedCaptions.getManifest(videoId); // Get the caption track infos
if (trackInfos.isEmpty) { var trackInfo = manifest.getByLanguage(en); // Get english caption.
// No caption is available. var track = await track.getByTime(duration); // Get the caption displayed at `duration`.
return;
}
var enTrack = trackInfos.firstWhere(
(e) => e.language.code == 'en'); // Find the english caption track.
if (enTrack == null) {
// The english track doesn't exist.
return;
}
var captionTrack = await yt.getClosedCaptionTrack(enTrack); // Get the english closed caption track
var captions = captionTrack.captions; // List of ClosedCaption
captions.first; // Get the first displayed caption.
captions.getByTime(7); // Get the caption displayed at the 7th second.
``` ```
## Cleanup ## Cleanup
@ -103,12 +85,10 @@ Available on [GitHub][Examples]
--- ---
Check the [api doc][API] for additional information. Check the [api doc][API] for additional information.
More features are provided through extensions.
[YoutubeExplode]: https://github.com/Tyrrrz/YoutubeExplode/ [YoutubeExplode]: https://github.com/Tyrrrz/YoutubeExplode/
[Video]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/Video-class.html [Video]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/Video-class.html
[MediaStreamsInfoSet]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/MediaStreamInfoSet-class.html
[VidExample]: https://github.com/Hexer10/youtube_explode_dart/blob/master/example/video_download.dart [VidExample]: https://github.com/Hexer10/youtube_explode_dart/blob/master/example/video_download.dart
[API]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/youtube_explode-library.html [API]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/youtube_explode-library.html
[Examples]: [https://github.com/Hexer10/youtube_explode_dart/tree/master/example] [Examples]: [https://github.com/Hexer10/youtube_explode_dart/tree/master/example]

View File

@ -1,6 +1,6 @@
name: youtube_explode_dart name: youtube_explode_dart
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key. description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
version: 1.0.2-beta version: 1.0.0
homepage: https://github.com/Hexer10/youtube_explode_dart homepage: https://github.com/Hexer10/youtube_explode_dart
environment: environment:

View File

@ -21,7 +21,7 @@ void main() {
var trackInfo = manifest.tracks.first; var trackInfo = manifest.tracks.first;
var track = await yt.videos.closedCaptions.get(trackInfo); var track = await yt.videos.closedCaptions.get(trackInfo);
expect(track, isNotEmpty); expect(track.captions, isNotEmpty);
}); });
test('GetClosedCaptionTrackAtSpecificTime', () async { test('GetClosedCaptionTrackAtSpecificTime', () async {
var manifest = await yt.videos.closedCaptions var manifest = await yt.videos.closedCaptions

View File

@ -29,7 +29,7 @@ void main() {
await yt.videos.streamsClient.getManifest(VideoId(videoId)); await yt.videos.streamsClient.getManifest(VideoId(videoId));
expect(manifest.streams, isNotEmpty); expect(manifest.streams, isNotEmpty);
} }
}, skip: 'Working on it.'); });
test('GetStreamOfUnplayableVideo', () async { test('GetStreamOfUnplayableVideo', () async {
expect(yt.videos.streamsClient.getManifest(VideoId('5qap5aO4i9A')), expect(yt.videos.streamsClient.getManifest(VideoId('5qap5aO4i9A')),
@ -58,7 +58,6 @@ void main() {
'rsAAeyAr-9Y', 'rsAAeyAr-9Y',
}; };
for (var videoId in data) { for (var videoId in data) {
print('Matchin $videoId');
var manifest = var manifest =
await yt.videos.streamsClient.getManifest(VideoId(videoId)); await yt.videos.streamsClient.getManifest(VideoId(videoId));
for (var streamInfo in manifest.streams) { for (var streamInfo in manifest.streams) {
@ -66,8 +65,6 @@ void main() {
expect(stream, isNotEmpty); expect(stream, isNotEmpty);
} }
} }
}, }, timeout: const Timeout(Duration(minutes: 10)), skip: 'Takes too long.');
timeout: const Timeout(Duration(minutes: 10)),
skip: 'Currently now working.');
}); });
} }