aboutsummaryrefslogtreecommitdiff
path: root/test/test_youtube_subtitles.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-06-26 11:03:44 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-07-20 12:52:25 +0200
commit5d51a883c2049e0186074ded9405b01f79470d57 (patch)
treefcfba0ffccc219a1f7708f77786c4ad494fe1c7a /test/test_youtube_subtitles.py
parentc4a91be726bd2892931a061ef6703b9bfce2a2d2 (diff)
Use a dictionary for storing the subtitles
The errors while getting the subtitles are reported as warnings, if no subtitles are found return and empty dict.
Diffstat (limited to 'test/test_youtube_subtitles.py')
-rw-r--r--test/test_youtube_subtitles.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/test_youtube_subtitles.py b/test/test_youtube_subtitles.py
index 86e09c9b1..fe0eac680 100644
--- a/test/test_youtube_subtitles.py
+++ b/test/test_youtube_subtitles.py
@@ -35,47 +35,47 @@ class TestYoutubeSubtitles(unittest.TestCase):
DL.params['writesubtitles'] = True
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
- sub = info_dict[0]['subtitles'][0]
- self.assertEqual(md5(sub[2]), '4cd9278a35ba2305f47354ee13472260')
+ sub = info_dict[0]['subtitles']['en']
+ self.assertEqual(md5(sub), '4cd9278a35ba2305f47354ee13472260')
def test_youtube_subtitles_it(self):
DL = FakeYDL()
DL.params['writesubtitles'] = True
DL.params['subtitleslang'] = 'it'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
- sub = info_dict[0]['subtitles'][0]
- self.assertEqual(md5(sub[2]), '164a51f16f260476a05b50fe4c2f161d')
+ sub = info_dict[0]['subtitles']['it']
+ self.assertEqual(md5(sub), '164a51f16f260476a05b50fe4c2f161d')
def test_youtube_onlysubtitles(self):
DL = FakeYDL()
DL.params['writesubtitles'] = True
DL.params['onlysubtitles'] = True
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
- sub = info_dict[0]['subtitles'][0]
- self.assertEqual(md5(sub[2]), '4cd9278a35ba2305f47354ee13472260')
+ sub = info_dict[0]['subtitles']['en']
+ self.assertEqual(md5(sub), '4cd9278a35ba2305f47354ee13472260')
def test_youtube_allsubtitles(self):
DL = FakeYDL()
DL.params['allsubtitles'] = True
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
subtitles = info_dict[0]['subtitles']
- self.assertEqual(len(subtitles), 13)
+ self.assertEqual(len(subtitles.keys()), 13)
def test_youtube_subtitles_sbv_format(self):
DL = FakeYDL()
DL.params['writesubtitles'] = True
DL.params['subtitlesformat'] = 'sbv'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
- sub = info_dict[0]['subtitles'][0]
- self.assertEqual(md5(sub[2]), '13aeaa0c245a8bed9a451cb643e3ad8b')
+ sub = info_dict[0]['subtitles']['en']
+ self.assertEqual(md5(sub), '13aeaa0c245a8bed9a451cb643e3ad8b')
def test_youtube_subtitles_vtt_format(self):
DL = FakeYDL()
DL.params['writesubtitles'] = True
DL.params['subtitlesformat'] = 'vtt'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
- sub = info_dict[0]['subtitles'][0]
- self.assertEqual(md5(sub[2]), '356cdc577fde0c6783b9b822e7206ff7')
+ sub = info_dict[0]['subtitles']['en']
+ self.assertEqual(md5(sub), '356cdc577fde0c6783b9b822e7206ff7')
def test_youtube_list_subtitles(self):
DL = FakeYDL()
DL.params['listsubtitles'] = True
@@ -88,8 +88,8 @@ class TestYoutubeSubtitles(unittest.TestCase):
DL.params['subtitleslang'] = 'it'
IE = YoutubeIE(DL)
info_dict = IE.extract('8YoUxe5ncPo')
- sub = info_dict[0]['subtitles'][0]
- self.assertTrue(sub[2] is not None)
+ sub = info_dict[0]['subtitles']['it']
+ self.assertTrue(sub is not None)
if __name__ == '__main__':
unittest.main()