Merge pull request #936 from iemejia/master
Added option for vtt WebVTT subtitle format for Youtube
This commit is contained in:
commit
52e8e1dc88
|
@ -116,12 +116,13 @@ which means you can modify it, redistribute it or use it however you like.
|
||||||
-F, --list-formats list all available formats (currently youtube
|
-F, --list-formats list all available formats (currently youtube
|
||||||
only)
|
only)
|
||||||
--write-sub write subtitle file (currently youtube only)
|
--write-sub write subtitle file (currently youtube only)
|
||||||
|
--write-auto-sub write automatic subtitle file (currently youtube only)
|
||||||
--only-sub [deprecated] alias of --skip-download
|
--only-sub [deprecated] alias of --skip-download
|
||||||
--all-subs downloads all the available subtitles of the
|
--all-subs downloads all the available subtitles of the
|
||||||
video (currently youtube only)
|
video (currently youtube only)
|
||||||
--list-subs lists all available subtitles for the video
|
--list-subs lists all available subtitles for the video
|
||||||
(currently youtube only)
|
(currently youtube only)
|
||||||
--sub-format FORMAT subtitle format [srt/sbv] (default=srt)
|
--sub-format FORMAT subtitle format [srt/sbv/vtt] (default=srt)
|
||||||
(currently youtube only)
|
(currently youtube only)
|
||||||
--sub-lang LANG language of the subtitles to download (optional)
|
--sub-lang LANG language of the subtitles to download (optional)
|
||||||
use IETF language tags like 'en'
|
use IETF language tags like 'en'
|
||||||
|
|
|
@ -84,7 +84,7 @@ class TestYoutubeSubtitles(unittest.TestCase):
|
||||||
info_dict = IE.extract('QRS8MkLhQmM')
|
info_dict = IE.extract('QRS8MkLhQmM')
|
||||||
subtitles = info_dict[0]['subtitles']
|
subtitles = info_dict[0]['subtitles']
|
||||||
self.assertEqual(len(subtitles), 13)
|
self.assertEqual(len(subtitles), 13)
|
||||||
def test_youtube_subtitles_format(self):
|
def test_youtube_subtitles_sbv_format(self):
|
||||||
DL = FakeYDL()
|
DL = FakeYDL()
|
||||||
DL.params['writesubtitles'] = True
|
DL.params['writesubtitles'] = True
|
||||||
DL.params['subtitlesformat'] = 'sbv'
|
DL.params['subtitlesformat'] = 'sbv'
|
||||||
|
@ -92,6 +92,14 @@ class TestYoutubeSubtitles(unittest.TestCase):
|
||||||
info_dict = IE.extract('QRS8MkLhQmM')
|
info_dict = IE.extract('QRS8MkLhQmM')
|
||||||
sub = info_dict[0]['subtitles'][0]
|
sub = info_dict[0]['subtitles'][0]
|
||||||
self.assertEqual(md5(sub[2]), '13aeaa0c245a8bed9a451cb643e3ad8b')
|
self.assertEqual(md5(sub[2]), '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')
|
||||||
def test_youtube_list_subtitles(self):
|
def test_youtube_list_subtitles(self):
|
||||||
DL = FakeYDL()
|
DL = FakeYDL()
|
||||||
DL.params['listsubtitles'] = True
|
DL.params['listsubtitles'] = True
|
||||||
|
|
|
@ -75,7 +75,7 @@ class YoutubeDL(object):
|
||||||
writeautomaticsub: Write the automatic subtitles to a file
|
writeautomaticsub: Write the automatic subtitles to a file
|
||||||
allsubtitles: Downloads all the subtitles of the video
|
allsubtitles: Downloads all the subtitles of the video
|
||||||
listsubtitles: Lists all available subtitles for the video
|
listsubtitles: Lists all available subtitles for the video
|
||||||
subtitlesformat: Subtitle format [sbv/srt] (default=srt)
|
subtitlesformat: Subtitle format [srt/sbv/vtt] (default=srt)
|
||||||
subtitleslang: Language of the subtitles to download
|
subtitleslang: Language of the subtitles to download
|
||||||
keepvideo: Keep the video file after post-processing
|
keepvideo: Keep the video file after post-processing
|
||||||
daterange: A DateRange object, download only if the upload_date is in the range.
|
daterange: A DateRange object, download only if the upload_date is in the range.
|
||||||
|
|
|
@ -205,7 +205,7 @@ def parseOpts(overrideArguments=None):
|
||||||
help='lists all available subtitles for the video (currently youtube only)', default=False)
|
help='lists all available subtitles for the video (currently youtube only)', default=False)
|
||||||
video_format.add_option('--sub-format',
|
video_format.add_option('--sub-format',
|
||||||
action='store', dest='subtitlesformat', metavar='FORMAT',
|
action='store', dest='subtitlesformat', metavar='FORMAT',
|
||||||
help='subtitle format [srt/sbv] (default=srt) (currently youtube only)', default='srt')
|
help='subtitle format [srt/sbv/vtt] (default=srt) (currently youtube only)', default='srt')
|
||||||
video_format.add_option('--sub-lang', '--srt-lang',
|
video_format.add_option('--sub-lang', '--srt-lang',
|
||||||
action='store', dest='subtitleslang', metavar='LANG',
|
action='store', dest='subtitleslang', metavar='LANG',
|
||||||
help='language of the subtitles to download (optional) use IETF language tags like \'en\'')
|
help='language of the subtitles to download (optional) use IETF language tags like \'en\'')
|
||||||
|
|
Loading…
Reference in New Issue