diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_download.py | 2 | ||||
-rw-r--r-- | test/test_utils.py | 16 | ||||
-rw-r--r-- | test/test_youtube_lists.py | 11 | ||||
-rw-r--r-- | test/test_youtube_subtitles.py | 2 | ||||
-rw-r--r-- | test/tests.json | 74 |
5 files changed, 96 insertions, 9 deletions
diff --git a/test/test_download.py b/test/test_download.py index cf8028718..3eca333f2 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -67,7 +67,7 @@ class TestDownload(unittest.TestCase): def generator(test_case): def test_template(self): - ie = youtube_dl.InfoExtractors.get_info_extractor(test_case['name'])#getattr(youtube_dl.InfoExtractors, test_case['name'] + 'IE') + ie = youtube_dl.InfoExtractors.get_info_extractor(test_case['name']) if not ie._WORKING: print('Skipping: IE marked as not _WORKING') return diff --git a/test/test_utils.py b/test/test_utils.py index eeaaa7fad..c4b71362e 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -14,6 +14,8 @@ from youtube_dl.utils import timeconvert from youtube_dl.utils import sanitize_filename from youtube_dl.utils import unescapeHTML from youtube_dl.utils import orderedSet +from youtube_dl.utils import DateRange +from youtube_dl.utils import unified_strdate if sys.version_info < (3, 0): _compat_str = lambda b: b.decode('unicode-escape') @@ -95,6 +97,20 @@ class TestUtil(unittest.TestCase): def test_unescape_html(self): self.assertEqual(unescapeHTML(_compat_str('%20;')), _compat_str('%20;')) + + def test_daterange(self): + _20century = DateRange("19000101","20000101") + self.assertFalse("17890714" in _20century) + _ac = DateRange("00010101") + self.assertTrue("19690721" in _ac) + _firstmilenium = DateRange(end="10000101") + self.assertTrue("07110427" in _firstmilenium) + + def test_unified_dates(self): + self.assertEqual(unified_strdate('December 21, 2010'), '20101221') + self.assertEqual(unified_strdate('8/7/2009'), '20090708') + self.assertEqual(unified_strdate('Dec 14, 2012'), '20121214') + self.assertEqual(unified_strdate('2012/10/11 01:56:38 +0000'), '20121011') if __name__ == '__main__': unittest.main() diff --git a/test/test_youtube_lists.py b/test/test_youtube_lists.py index c7f00af32..78657b51c 100644 --- a/test/test_youtube_lists.py +++ b/test/test_youtube_lists.py @@ -29,7 +29,7 @@ class FakeDownloader(FileDownloader): self.params = parameters def to_screen(self, s): print(s) - def trouble(self, s): + def trouble(self, s, tb=None): raise Exception(s) def extract_info(self, url): self.result.append(url) @@ -71,6 +71,13 @@ class TestYoutubeLists(unittest.TestCase): ytie_results = [YoutubeIE()._extract_id(url['url']) for url in result['entries']] self.assertFalse('pElCt5oNDuI' in ytie_results) self.assertFalse('KdPEApIVdWM' in ytie_results) + + def test_youtube_playlist_empty(self): + dl = FakeDownloader() + ie = YoutubePlaylistIE(dl) + result = ie.extract('https://www.youtube.com/playlist?list=PLtPgu7CB4gbZDA7i_euNxn75ISqxwZPYx')[0] + self.assertIsPlaylist(result) + self.assertEqual(len(result['entries']), 0) def test_youtube_course(self): dl = FakeDownloader() @@ -90,7 +97,7 @@ class TestYoutubeLists(unittest.TestCase): self.assertTrue(len(result['entries']) > 90) #test autogenerated channel result = ie.extract('https://www.youtube.com/channel/HCtnHdj3df7iM/videos')[0] - self.assertTrue(len(result['entries']) > 20) + self.assertTrue(len(result['entries']) >= 18) def test_youtube_user(self): dl = FakeDownloader() diff --git a/test/test_youtube_subtitles.py b/test/test_youtube_subtitles.py index b4909091b..5b3f289af 100644 --- a/test/test_youtube_subtitles.py +++ b/test/test_youtube_subtitles.py @@ -30,7 +30,7 @@ class FakeDownloader(object): self.params = parameters def to_screen(self, s): print(s) - def trouble(self, s): + def trouble(self, s, tb=None): raise Exception(s) def download(self, x): self.result.append(x) diff --git a/test/tests.json b/test/tests.json index 2b56738a0..b4d511dd8 100644 --- a/test/tests.json +++ b/test/tests.json @@ -112,9 +112,8 @@ { "name": "Escapist", "url": "http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate", - "file": "6618-Breaking-Down-Baldurs-Gate.flv", - "md5": "c6793dbda81388f4264c1ba18684a74d", - "skip": "Fails with timeout on Travis" + "file": "6618-Breaking-Down-Baldurs-Gate.mp4", + "md5": "c6793dbda81388f4264c1ba18684a74d" }, { "name": "GooglePlus", @@ -344,8 +343,73 @@ "file": "17258355236.mp4", "md5": "7c6a514d691b034ccf8567999e9e88a3", "info_dict": { - "title": "A sample video from LeeAnn. (If you need an idea..." + "title": "Calling all Pris! - A sample video from LeeAnn. (If you need an idea..." + } + }, + { + "name": "SoundcloudSet", + "url":"https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep", + "playlist":[ + { + "file":"30510138.mp3", + "md5":"f9136bf103901728f29e419d2c70f55d", + "info_dict": { + "title":"D-D-Dance" + } + }, + { + "file":"47127625.mp3", + "md5":"09b6758a018470570f8fd423c9453dd8", + "info_dict": { + "title":"The Royal Concept - Gimme Twice" + } + }, + { + "file":"47127627.mp3", + "md5":"154abd4e418cea19c3b901f1e1306d9c", + "info_dict": { + "title":"Goldrushed" + } + }, + { + "file":"47127629.mp3", + "md5":"2f5471edc79ad3f33a683153e96a79c1", + "info_dict": { + "title":"In the End" + } + }, + { + "file":"47127631.mp3", + "md5":"f9ba87aa940af7213f98949254f1c6e2", + "info_dict": { + "title":"Knocked Up" + } + }, + { + "file":"75206121.mp3", + "md5":"f9d1fe9406717e302980c30de4af9353", + "info_dict": { + "title":"World On Fire" + } + } + ] + }, + { + "name":"Bandcamp", + "url":"http://youtube-dl.bandcamp.com/track/youtube-dl-test-song", + "file":"1812978515.mp3", + "md5":"cdeb30cdae1921719a3cbcab696ef53c", + "info_dict": { + "title":"youtube-dl test song \"'/\\ä↭" + } + }, + { + "name": "RedTube", + "url": "http://www.redtube.com/66418", + "file": "66418.mp4", + "md5": "7b8c22b5e7098a3e1c09709df1126d2d", + "info_dict":{ + "title":"Sucked on a toilet" } } - ] |