youtube_explode/test/playlist_test.dart

72 lines
2.6 KiB
Dart
Raw Permalink Normal View History

2020-06-05 16:17:08 +02:00
import 'package:test/test.dart';
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
void main() {
2021-03-11 14:20:10 +01:00
YoutubeExplode? yt;
2020-10-27 14:44:11 +01:00
setUpAll(() {
2020-10-17 22:09:52 +02:00
yt = YoutubeExplode();
});
2020-10-27 14:44:11 +01:00
tearDownAll(() {
2021-03-11 14:20:10 +01:00
yt?.close();
2020-10-17 22:09:52 +02:00
});
2020-06-05 16:17:08 +02:00
2020-10-17 22:09:52 +02:00
test('Get metadata of a playlist', () async {
var playlistUrl =
2022-04-30 17:49:34 +02:00
'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd';
2021-03-11 14:20:10 +01:00
var playlist = await yt!.playlists.get(PlaylistId(playlistUrl));
2020-10-17 22:09:52 +02:00
expect(playlist.id.value, 'PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd');
expect(playlist.url, playlistUrl);
expect(playlist.title, 'osu! Highlights');
expect(playlist.author, 'Tyrrrz');
expect(playlist.description, 'My best osu! plays');
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(133));
2021-03-04 10:46:37 +01:00
expect(playlist.engagement.likeCount, isNull);
expect(playlist.engagement.dislikeCount, isNull);
2020-10-17 22:09:52 +02:00
expect(playlist.thumbnails.lowResUrl, isNotEmpty);
expect(playlist.thumbnails.mediumResUrl, isNotEmpty);
expect(playlist.thumbnails.highResUrl, isNotEmpty);
expect(playlist.thumbnails.standardResUrl, isNotEmpty);
expect(playlist.thumbnails.maxResUrl, isNotEmpty);
2021-08-29 13:26:21 +02:00
expect(playlist.videoCount, greaterThanOrEqualTo(20));
2020-10-17 22:09:52 +02:00
});
group('Get metadata of any playlist', () {
2021-03-11 14:20:10 +01:00
for (final val in {
2020-10-17 22:09:52 +02:00
PlaylistId('PLI5YfMzCfRtZ8eV576YoY3vIYrHjyVm_e'),
PlaylistId('RD1hu8-y6fKg0'),
PlaylistId('RDMMU-ty-2B02VY'),
PlaylistId('RDCLAK5uy_lf8okgl2ygD075nhnJVjlfhwp8NsUgEbs'),
PlaylistId('PL601B2E69B03FAB9D')
}) {
test('PlaylistID - ${val.value}', () async {
2021-03-11 14:20:10 +01:00
var playlist = await yt!.playlists.get(val);
2020-10-17 22:09:52 +02:00
expect(playlist.id.value, val.value);
});
}
});
2021-03-19 09:20:49 +01:00
test('Get more than 100 videos in a playlist', () async {
var videos = await yt!.playlists
.getVideos(PlaylistId(
2022-04-30 17:49:34 +02:00
'http://127.0.0.1:8080/www.youtube.com:443/playlist?list=PLCSusC_jlo14J0uBgFqfHsKu7gc5W2HyM'))
2021-03-19 09:20:49 +01:00
.toList();
expect(videos.length, greaterThan(100));
});
2020-10-17 22:09:52 +02:00
group('Get videos in any playlist', () {
2021-03-11 14:20:10 +01:00
for (final val in {
2020-10-17 22:09:52 +02:00
PlaylistId('PLI5YfMzCfRtZ8eV576YoY3vIYrHjyVm_e'),
PlaylistId('PLWwAypAcFRgKFlxtLbn_u14zddtDJj3mk'),
PlaylistId('OLAK5uy_mtOdjCW76nDvf5yOzgcAVMYpJ5gcW5uKU'),
PlaylistId('RDCLAK5uy_lf8okgl2ygD075nhnJVjlfhwp8NsUgEbs'),
PlaylistId('UUTMt7iMWa7jy0fNXIktwyLA'),
2021-03-04 10:46:37 +01:00
PlaylistId('OLAK5uy_lLeonUugocG5J0EUAEDmbskX4emejKwcM'),
PlaylistId('PL601B2E69B03FAB9D'),
2020-10-17 22:09:52 +02:00
}) {
test('PlaylistID - ${val.value}', () async {
2021-03-11 14:20:10 +01:00
expect(yt!.playlists.getVideos(val), emits(isNotNull));
2020-06-22 17:40:57 +02:00
});
}
2020-06-05 16:17:08 +02:00
});
}