Skip to content

Commit

Permalink
[YoutubeDL] Autocalculate ext for subtitles when missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Oct 4, 2015
1 parent ef5acfe commit 4bba371
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions youtube_dl/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,20 @@ def process_video_result(self, info_dict, download=True):
except (ValueError, OverflowError, OSError):
pass

subtitles = info_dict.get('subtitles')
if subtitles:
for _, subtitle in subtitles.items():
for subtitle_format in subtitle:
if 'ext' not in subtitle_format:
subtitle_format['ext'] = determine_ext(subtitle_format['url']).lower()

if self.params.get('listsubtitles', False):
if 'automatic_captions' in info_dict:
self.list_subtitles(info_dict['id'], info_dict.get('automatic_captions'), 'automatic captions')
self.list_subtitles(info_dict['id'], info_dict.get('subtitles'), 'subtitles')
self.list_subtitles(info_dict['id'], subtitles, 'subtitles')
return
info_dict['requested_subtitles'] = self.process_subtitles(
info_dict['id'], info_dict.get('subtitles'),
info_dict['id'], subtitles,
info_dict.get('automatic_captions'))

# We now pick which formats have to be downloaded
Expand Down
1 change: 1 addition & 0 deletions youtube_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class InfoExtractor(object):
with the "ext" entry and one of:
* "data": The subtitles file contents
* "url": A URL pointing to the subtitles file
"ext" will be calculated from URL if missing
automatic_captions: Like 'subtitles', used by the YoutubeIE for
automatically generated captions
duration: Length of the video in seconds, as an integer.
Expand Down

0 comments on commit 4bba371

Please sign in to comment.