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