]>
jfr.im git - yt-dlp.git/blob - test/test_all_urls.py
6 # Allow direct execution
8 sys
.path
.append(os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
10 from youtube_dl
.extractor
import YoutubeIE
, YoutubePlaylistIE
, YoutubeChannelIE
, JustinTVIE
, gen_extractors
11 from helper
import get_testcases
13 class TestAllURLsMatching(unittest
.TestCase
):
14 def test_youtube_playlist_matching(self
):
15 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8'))
16 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'UUBABnxM4Ar9ten8Mdjj1j0Q')) #585
17 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'PL63F0C78739B09958'))
18 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/playlist?list=UUBABnxM4Ar9ten8Mdjj1j0Q'))
19 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8'))
20 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/playlist?list=PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC'))
21 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/watch?v=AV6J6_AeFEQ&playnext=1&list=PL4023E734DA416012')) #668
22 self
.assertFalse(YoutubePlaylistIE
.suitable(u
'PLtS2H6bU1M'))
24 def test_youtube_matching(self
):
25 self
.assertTrue(YoutubeIE
.suitable(u
'PLtS2H6bU1M'))
26 self
.assertFalse(YoutubeIE
.suitable(u
'https://www.youtube.com/watch?v=AV6J6_AeFEQ&playnext=1&list=PL4023E734DA416012')) #668
28 def test_youtube_channel_matching(self
):
29 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM'))
30 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM?feature=gb_ch_rec'))
31 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM/videos'))
33 def test_justin_tv_channelid_matching(self
):
34 self
.assertTrue(JustinTVIE
.suitable(u
"justin.tv/vanillatv"))
35 self
.assertTrue(JustinTVIE
.suitable(u
"twitch.tv/vanillatv"))
36 self
.assertTrue(JustinTVIE
.suitable(u
"www.justin.tv/vanillatv"))
37 self
.assertTrue(JustinTVIE
.suitable(u
"www.twitch.tv/vanillatv"))
38 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.justin.tv/vanillatv"))
39 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv"))
40 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.justin.tv/vanillatv/"))
41 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv/"))
43 def test_justintv_videoid_matching(self
):
44 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv/b/328087483"))
46 def test_justin_tv_chapterid_matching(self
):
47 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/tsm_theoddone/c/2349361"))
49 def test_youtube_extract(self
):
50 self
.assertEqual(YoutubeIE()._extract
_id
('http://www.youtube.com/watch?&v=BaW_jenozKc'), 'BaW_jenozKc')
51 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch?&v=BaW_jenozKc'), 'BaW_jenozKc')
52 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch?feature=player_embedded&v=BaW_jenozKc'), 'BaW_jenozKc')
53 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch_popup?v=BaW_jenozKc'), 'BaW_jenozKc')
55 def test_no_duplicates(self
):
56 ies
= gen_extractors()
57 for tc
in get_testcases():
60 if type(ie
).__name
__ in ['GenericIE', tc
['name'] + 'IE']:
61 self
.assertTrue(ie
.suitable(url
), '%s should match URL %r' % (type(ie
).__name
__, url
))
63 self
.assertFalse(ie
.suitable(url
), '%s should not match URL %r' % (type(ie
).__name
__, url
))
65 def test_keywords(self
):
66 ies
= gen_extractors()
67 matching_ies
= lambda url
: [ie
.IE_NAME
for ie
in ies
68 if ie
.suitable(url
) and ie
.IE_NAME
!= 'generic']
69 self
.assertEqual(matching_ies(':ytsubs'), ['youtube:subscriptions'])
70 self
.assertEqual(matching_ies(':ytsubscriptions'), ['youtube:subscriptions'])
71 self
.assertEqual(matching_ies(':thedailyshow'), ['ComedyCentral'])
72 self
.assertEqual(matching_ies(':tds'), ['ComedyCentral'])
73 self
.assertEqual(matching_ies(':colbertreport'), ['ComedyCentral'])
74 self
.assertEqual(matching_ies(':cr'), ['ComedyCentral'])
77 if __name__
== '__main__':