]>
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
):
15 self
.ies
= gen_extractors()
17 def matching_ies(self
, url
):
18 return [ie
.IE_NAME
for ie
in self
.ies
if ie
.suitable(url
) and ie
.IE_NAME
!= 'generic']
20 def assertMatch(self
, url
, ie_list
):
21 self
.assertEqual(self
.matching_ies(url
), ie_list
)
23 def test_youtube_playlist_matching(self
):
24 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8'))
25 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'UUBABnxM4Ar9ten8Mdjj1j0Q')) #585
26 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'PL63F0C78739B09958'))
27 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/playlist?list=UUBABnxM4Ar9ten8Mdjj1j0Q'))
28 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/course?list=ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8'))
29 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/playlist?list=PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC'))
30 self
.assertTrue(YoutubePlaylistIE
.suitable(u
'https://www.youtube.com/watch?v=AV6J6_AeFEQ&playnext=1&list=PL4023E734DA416012')) #668
31 self
.assertFalse(YoutubePlaylistIE
.suitable(u
'PLtS2H6bU1M'))
33 def test_youtube_matching(self
):
34 self
.assertTrue(YoutubeIE
.suitable(u
'PLtS2H6bU1M'))
35 self
.assertFalse(YoutubeIE
.suitable(u
'https://www.youtube.com/watch?v=AV6J6_AeFEQ&playnext=1&list=PL4023E734DA416012')) #668
36 self
.assertMatch('http://youtu.be/BaW_jenozKc', ['youtube'])
37 self
.assertMatch('http://www.youtube.com/v/BaW_jenozKc', ['youtube'])
39 def test_youtube_channel_matching(self
):
40 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM'))
41 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM?feature=gb_ch_rec'))
42 self
.assertTrue(YoutubeChannelIE
.suitable('https://www.youtube.com/channel/HCtnHdj3df7iM/videos'))
44 def test_youtube_user_matching(self
):
45 self
.assertMatch('www.youtube.com/NASAgovVideo/videos', ['youtube:user'])
47 def test_justin_tv_channelid_matching(self
):
48 self
.assertTrue(JustinTVIE
.suitable(u
"justin.tv/vanillatv"))
49 self
.assertTrue(JustinTVIE
.suitable(u
"twitch.tv/vanillatv"))
50 self
.assertTrue(JustinTVIE
.suitable(u
"www.justin.tv/vanillatv"))
51 self
.assertTrue(JustinTVIE
.suitable(u
"www.twitch.tv/vanillatv"))
52 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.justin.tv/vanillatv"))
53 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv"))
54 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.justin.tv/vanillatv/"))
55 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv/"))
57 def test_justintv_videoid_matching(self
):
58 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/vanillatv/b/328087483"))
60 def test_justin_tv_chapterid_matching(self
):
61 self
.assertTrue(JustinTVIE
.suitable(u
"http://www.twitch.tv/tsm_theoddone/c/2349361"))
63 def test_youtube_extract(self
):
64 self
.assertEqual(YoutubeIE()._extract
_id
('http://www.youtube.com/watch?&v=BaW_jenozKc'), 'BaW_jenozKc')
65 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch?&v=BaW_jenozKc'), 'BaW_jenozKc')
66 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch?feature=player_embedded&v=BaW_jenozKc'), 'BaW_jenozKc')
67 self
.assertEqual(YoutubeIE()._extract
_id
('https://www.youtube.com/watch_popup?v=BaW_jenozKc'), 'BaW_jenozKc')
69 def test_no_duplicates(self
):
70 ies
= gen_extractors()
71 for tc
in get_testcases():
74 if type(ie
).__name
__ in ['GenericIE', tc
['name'] + 'IE']:
75 self
.assertTrue(ie
.suitable(url
), '%s should match URL %r' % (type(ie
).__name
__, url
))
77 self
.assertFalse(ie
.suitable(url
), '%s should not match URL %r' % (type(ie
).__name
__, url
))
79 def test_keywords(self
):
80 self
.assertMatch(':ytsubs', ['youtube:subscriptions'])
81 self
.assertMatch(':ytsubscriptions', ['youtube:subscriptions'])
82 self
.assertMatch(':thedailyshow', ['ComedyCentral'])
83 self
.assertMatch(':tds', ['ComedyCentral'])
84 self
.assertMatch(':colbertreport', ['ComedyCentral'])
85 self
.assertMatch(':cr', ['ComedyCentral'])
88 if __name__
== '__main__':