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
- No need for an API key and no usage quotas
- All model extend `Equatable` to easily perform equality checks
- Download Stream
## 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)
```yaml
youtube_explode_dart: ^1.0.0-beta
youtube_explode_dart: ^1.0.0
```
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.
```
## 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]).
```dart
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.
## 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.
```dart
var trackInfos = await yt.getVideoClosedCaptionTrackInfos(id); // Get the caption track infos
if (trackInfos.isEmpty) {
// No caption is available.
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.
var trackInfos = await yt.videos.closedCaptions.getManifest(videoId); // Get the caption track infos
var trackInfo = manifest.getByLanguage(en); // Get english caption.
var track = await track.getByTime(duration); // Get the caption displayed at `duration`.
```
## Cleanup
@ -103,12 +85,10 @@ Available on [GitHub][Examples]
---
Check the [api doc][API] for additional information.
More features are provided through extensions.
[YoutubeExplode]: https://github.com/Tyrrrz/YoutubeExplode/
[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
[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]

View File

@ -1,6 +1,6 @@
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.
version: 1.0.2-beta
version: 1.0.0
homepage: https://github.com/Hexer10/youtube_explode_dart
environment:

View File

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

View File

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