2020-06-05 16:17:08 +02:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
|
|
|
|
|
|
|
void main() {
|
2020-10-17 22:09:52 +02:00
|
|
|
YoutubeExplode yt;
|
2020-10-27 14:44:11 +01:00
|
|
|
setUpAll(() {
|
2020-10-17 22:09:52 +02:00
|
|
|
yt = YoutubeExplode();
|
|
|
|
});
|
2020-06-05 16:17:08 +02:00
|
|
|
|
2020-10-27 14:44:11 +01:00
|
|
|
tearDownAll(() {
|
2020-10-17 22:09:52 +02:00
|
|
|
yt.close();
|
|
|
|
});
|
2020-06-05 16:17:08 +02:00
|
|
|
|
2020-12-25 23:29:01 +01:00
|
|
|
group('Get streams manifest of any video', () {
|
2020-10-17 22:09:52 +02:00
|
|
|
for (var val in {
|
2020-12-25 23:29:01 +01:00
|
|
|
VideoId('9bZkp7q19f0'), // very popular
|
|
|
|
VideoId('SkRSXFQerZs'), // age restricted (embed allowed)
|
|
|
|
VideoId('hySoCSoH-g8'), // age restricted (embed not allowed)
|
|
|
|
VideoId('_kmeFXjjGfk'), // embed not allowed (type 1)
|
|
|
|
VideoId('MeJVWBSsPAY'), // embed not allowed (type 2)
|
|
|
|
VideoId('5VGm0dczmHc'), // rating not allowed
|
2020-10-17 22:09:52 +02:00
|
|
|
VideoId('ZGdLIwrGHG8'), // unlisted
|
2020-12-25 23:29:01 +01:00
|
|
|
VideoId('rsAAeyAr-9Y'), // recording of a live stream
|
|
|
|
VideoId('AI7ULzgf8RU'), // has DASH manifest
|
|
|
|
VideoId('-xNN-bJQ4vI'), // 360° video
|
2020-10-17 22:09:52 +02:00
|
|
|
}) {
|
|
|
|
test('VideoId - ${val.value}', () async {
|
|
|
|
var manifest = await yt.videos.streamsClient.getManifest(val);
|
2020-06-05 16:17:08 +02:00
|
|
|
expect(manifest.streams, isNotEmpty);
|
2020-06-22 17:40:57 +02:00
|
|
|
});
|
|
|
|
}
|
2020-10-17 22:09:52 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Stream of paid videos throw VideoRequiresPurchaseException', () {
|
|
|
|
expect(yt.videos.streamsClient.getManifest(VideoId('p3dDcKOFXQg')),
|
|
|
|
throwsA(const TypeMatcher<VideoRequiresPurchaseException>()));
|
|
|
|
});
|
|
|
|
|
|
|
|
group('Stream of unavailable videos throws VideoUnavailableException', () {
|
|
|
|
for (var val in {VideoId('qld9w0b-1ao'), VideoId('pb_hHv3fByo')}) {
|
|
|
|
test('VideoId - ${val.value}', () {
|
|
|
|
expect(yt.videos.streamsClient.getManifest(val),
|
|
|
|
throwsA(const TypeMatcher<VideoUnavailableException>()));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-06-05 16:17:08 +02:00
|
|
|
|
2020-12-25 23:29:01 +01:00
|
|
|
group('Get specific stream of any playable video', () {
|
2020-10-17 22:09:52 +02:00
|
|
|
for (var val in {
|
2020-12-25 23:29:01 +01:00
|
|
|
VideoId('9bZkp7q19f0'), // very popular
|
|
|
|
VideoId('SkRSXFQerZs'), // age restricted (embed allowed)
|
|
|
|
VideoId('hySoCSoH-g8'), // age restricted (embed not allowed)
|
|
|
|
VideoId('_kmeFXjjGfk'), // embed not allowed (type 1)
|
|
|
|
VideoId('MeJVWBSsPAY'), // embed not allowed (type 2)
|
|
|
|
VideoId('5VGm0dczmHc'), // rating not allowed
|
2020-10-24 14:54:42 +02:00
|
|
|
VideoId('ZGdLIwrGHG8'), // unlisted
|
2020-12-25 23:29:01 +01:00
|
|
|
VideoId('rsAAeyAr-9Y'), // recording of a live stream
|
2021-01-28 10:32:09 +01:00
|
|
|
VideoId('AI7ULzgf8RU'), // has DASH manifest TODO: Test timesout
|
2020-12-25 23:29:01 +01:00
|
|
|
VideoId('-xNN-bJQ4vI'), // 360° video
|
2020-10-17 22:09:52 +02:00
|
|
|
}) {
|
|
|
|
test('VideoId - ${val.value}', () async {
|
|
|
|
var manifest = await yt.videos.streamsClient.getManifest(val);
|
2020-06-05 16:17:08 +02:00
|
|
|
for (var streamInfo in manifest.streams) {
|
2020-10-17 22:13:39 +02:00
|
|
|
expect(yt.videos.streamsClient.get(streamInfo), emits(isNotNull));
|
2020-06-05 16:17:08 +02:00
|
|
|
}
|
2020-10-17 22:09:52 +02:00
|
|
|
});
|
|
|
|
}
|
2020-10-27 14:44:11 +01:00
|
|
|
});
|
2020-06-05 16:17:08 +02:00
|
|
|
}
|