]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
54007a45 | 2 | |
44a5f171 PH |
3 | # Allow direct execution |
4 | import os | |
9789a05c FV |
5 | import sys |
6 | import unittest | |
f8271158 | 7 | |
44a5f171 PH |
8 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
9 | ||
9789a05c | 10 | |
54007a45 | 11 | from test.helper import FakeYDL, is_download_test |
f8271158 | 12 | from yt_dlp.extractor import YoutubeIE, YoutubeTabIE |
9789a05c | 13 | |
9789a05c | 14 | |
060ac762 | 15 | @is_download_test |
9789a05c | 16 | class TestYoutubeLists(unittest.TestCase): |
44a5f171 | 17 | def assertIsPlaylist(self, info): |
8a38a194 JMF |
18 | """Make sure the info has '_type' set to 'playlist'""" |
19 | self.assertEqual(info['_type'], 'playlist') | |
20 | ||
d4d9920a FV |
21 | def test_youtube_playlist_noplaylist(self): |
22 | dl = FakeYDL() | |
23 | dl.params['noplaylist'] = True | |
dd2a987d | 24 | ie = YoutubeTabIE(dl) |
d5a39898 | 25 | result = ie.extract('https://www.youtube.com/watch?v=OmJ-4B-mS-Y&list=PLydZ2Hrp_gPRJViZjLFKaBMgCQOYEEkyp&index=2') |
d4d9920a | 26 | self.assertEqual(result['_type'], 'url') |
d5a39898 | 27 | self.assertEqual(result['ie_key'], YoutubeIE.ie_key()) |
28 | self.assertEqual(YoutubeIE.extract_id(result['url']), 'OmJ-4B-mS-Y') | |
9789a05c | 29 | |
652cdaa2 JMF |
30 | def test_youtube_mix(self): |
31 | dl = FakeYDL() | |
dd2a987d | 32 | ie = YoutubeTabIE(dl) |
33 | result = ie.extract('https://www.youtube.com/watch?v=tyITL_exICo&list=RDCLAK5uy_kLWIr9gv1XLlPbaDS965-Db4TrBoUTxQ8') | |
34 | entries = list(result['entries']) | |
1b6182d8 | 35 | self.assertTrue(len(entries) >= 50) |
652cdaa2 | 36 | original_video = entries[0] |
dd2a987d | 37 | self.assertEqual(original_video['id'], 'tyITL_exICo') |
652cdaa2 | 38 | |
bc2ca1bb | 39 | def test_youtube_flat_playlist_extraction(self): |
8e5b1219 S |
40 | dl = FakeYDL() |
41 | dl.params['extract_flat'] = True | |
bc2ca1bb | 42 | ie = YoutubeTabIE(dl) |
43 | result = ie.extract('https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc') | |
8e5b1219 | 44 | self.assertIsPlaylist(result) |
bc2ca1bb | 45 | entries = list(result['entries']) |
46 | self.assertTrue(len(entries) == 1) | |
47 | video = entries[0] | |
dd2a987d | 48 | self.assertEqual(video['_type'], 'url') |
bc2ca1bb | 49 | self.assertEqual(video['ie_key'], 'Youtube') |
50 | self.assertEqual(video['id'], 'BaW_jenozKc') | |
dd2a987d | 51 | self.assertEqual(video['url'], 'https://www.youtube.com/watch?v=BaW_jenozKc') |
bc2ca1bb | 52 | self.assertEqual(video['title'], 'youtube-dl test video "\'/\\ä↭𝕐') |
53 | self.assertEqual(video['duration'], 10) | |
54 | self.assertEqual(video['uploader'], 'Philipp Hagemeister') | |
8e5b1219 | 55 | |
582be358 | 56 | |
9789a05c FV |
57 | if __name__ == '__main__': |
58 | unittest.main() |