mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-29 21:52:54 +00:00
Merge remote-tracking branch 'origin/master'
Conflicts: youtube_dl/YoutubeDL.py
This commit is contained in:
commit
7853cc5ae1
10 changed files with 162 additions and 102 deletions
|
@ -94,6 +94,40 @@ class TestFormatSelection(unittest.TestCase):
|
||||||
downloaded = ydl.downloaded_info_dicts[0]
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
self.assertEqual(downloaded[u'format_id'], u'excellent')
|
self.assertEqual(downloaded[u'format_id'], u'excellent')
|
||||||
|
|
||||||
|
def test_format_selection(self):
|
||||||
|
formats = [
|
||||||
|
{u'format_id': u'35', u'ext': u'mp4'},
|
||||||
|
{u'format_id': u'45', u'ext': u'webm'},
|
||||||
|
{u'format_id': u'47', u'ext': u'webm'},
|
||||||
|
{u'format_id': u'2', u'ext': u'flv'},
|
||||||
|
]
|
||||||
|
info_dict = {u'formats': formats, u'extractor': u'test'}
|
||||||
|
|
||||||
|
ydl = YDL({'format': u'20/47'})
|
||||||
|
ydl.process_ie_result(info_dict)
|
||||||
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
|
self.assertEqual(downloaded['format_id'], u'47')
|
||||||
|
|
||||||
|
ydl = YDL({'format': u'20/71/worst'})
|
||||||
|
ydl.process_ie_result(info_dict)
|
||||||
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
|
self.assertEqual(downloaded['format_id'], u'35')
|
||||||
|
|
||||||
|
ydl = YDL()
|
||||||
|
ydl.process_ie_result(info_dict)
|
||||||
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
|
self.assertEqual(downloaded['format_id'], u'2')
|
||||||
|
|
||||||
|
ydl = YDL({'format': u'webm/mp4'})
|
||||||
|
ydl.process_ie_result(info_dict)
|
||||||
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
|
self.assertEqual(downloaded['format_id'], u'47')
|
||||||
|
|
||||||
|
ydl = YDL({'format': u'3gp/40/mp4'})
|
||||||
|
ydl.process_ie_result(info_dict)
|
||||||
|
downloaded = ydl.downloaded_info_dicts[0]
|
||||||
|
self.assertEqual(downloaded['format_id'], u'35')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -234,19 +234,6 @@ class YoutubeDL(object):
|
||||||
error_message = u'%s %s' % (_msg_header, message)
|
error_message = u'%s %s' % (_msg_header, message)
|
||||||
self.trouble(error_message, tb)
|
self.trouble(error_message, tb)
|
||||||
|
|
||||||
def slow_down(self, start_time, byte_counter):
|
|
||||||
"""Sleep if the download speed is over the rate limit."""
|
|
||||||
rate_limit = self.params.get('ratelimit', None)
|
|
||||||
if rate_limit is None or byte_counter == 0:
|
|
||||||
return
|
|
||||||
now = time.time()
|
|
||||||
elapsed = now - start_time
|
|
||||||
if elapsed <= 0.0:
|
|
||||||
return
|
|
||||||
speed = float(byte_counter) / elapsed
|
|
||||||
if speed > rate_limit:
|
|
||||||
time.sleep((byte_counter - rate_limit * (now - start_time)) / rate_limit)
|
|
||||||
|
|
||||||
def report_writedescription(self, descfn):
|
def report_writedescription(self, descfn):
|
||||||
""" Report that the description file is being written """
|
""" Report that the description file is being written """
|
||||||
self.to_screen(u'[info] Writing video description to: ' + descfn)
|
self.to_screen(u'[info] Writing video description to: ' + descfn)
|
||||||
|
@ -450,6 +437,22 @@ class YoutubeDL(object):
|
||||||
else:
|
else:
|
||||||
raise Exception('Invalid result type: %s' % result_type)
|
raise Exception('Invalid result type: %s' % result_type)
|
||||||
|
|
||||||
|
def select_format(self, format_spec, available_formats):
|
||||||
|
if format_spec == 'best' or format_spec is None:
|
||||||
|
return available_formats[-1]
|
||||||
|
elif format_spec == 'worst':
|
||||||
|
return available_formats[0]
|
||||||
|
else:
|
||||||
|
extensions = [u'mp4', u'flv', u'webm', u'3gp']
|
||||||
|
if format_spec in extensions:
|
||||||
|
filter_f = lambda f: f['ext'] == format_spec
|
||||||
|
else:
|
||||||
|
filter_f = lambda f: f['format_id'] == format_spec
|
||||||
|
matches = list(filter(filter_f, available_formats))
|
||||||
|
if matches:
|
||||||
|
return matches[-1]
|
||||||
|
return None
|
||||||
|
|
||||||
def process_video_result(self, info_dict, download=True):
|
def process_video_result(self, info_dict, download=True):
|
||||||
assert info_dict.get('_type', 'video') == 'video'
|
assert info_dict.get('_type', 'video') == 'video'
|
||||||
|
|
||||||
|
@ -460,6 +463,7 @@ class YoutubeDL(object):
|
||||||
|
|
||||||
# This extractors handle format selection themselves
|
# This extractors handle format selection themselves
|
||||||
if info_dict['extractor'] in [u'youtube', u'Youku', u'YouPorn', u'mixcloud']:
|
if info_dict['extractor'] in [u'youtube', u'Youku', u'YouPorn', u'mixcloud']:
|
||||||
|
if download:
|
||||||
self.process_info(info_dict)
|
self.process_info(info_dict)
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
|
@ -472,17 +476,14 @@ class YoutubeDL(object):
|
||||||
|
|
||||||
# We check that all the formats have the format and format_id fields
|
# We check that all the formats have the format and format_id fields
|
||||||
for (i, format) in enumerate(formats):
|
for (i, format) in enumerate(formats):
|
||||||
if format.get('format') is None:
|
|
||||||
if format.get('height') is not None:
|
|
||||||
if format.get('width') is not None:
|
|
||||||
format_desc = u'%sx%s' % (format['width'], format['height'])
|
|
||||||
else:
|
|
||||||
format_desc = u'%sp' % format['height']
|
|
||||||
else:
|
|
||||||
format_desc = '???'
|
|
||||||
format['format'] = format_desc
|
|
||||||
if format.get('format_id') is None:
|
if format.get('format_id') is None:
|
||||||
format['format_id'] = compat_str(i)
|
format['format_id'] = compat_str(i)
|
||||||
|
if format.get('format') is None:
|
||||||
|
format['format'] = u'{id} - {res}{note}'.format(
|
||||||
|
id=format['format_id'],
|
||||||
|
res=self.format_resolution(format),
|
||||||
|
note=u' ({})'.format(format['format_note']) if format.get('format_note') is not None else '',
|
||||||
|
)
|
||||||
|
|
||||||
if self.params.get('listformats', None):
|
if self.params.get('listformats', None):
|
||||||
self.list_formats(info_dict)
|
self.list_formats(info_dict)
|
||||||
|
@ -504,22 +505,20 @@ class YoutubeDL(object):
|
||||||
formats = sorted(formats, key=_free_formats_key)
|
formats = sorted(formats, key=_free_formats_key)
|
||||||
|
|
||||||
req_format = self.params.get('format', 'best')
|
req_format = self.params.get('format', 'best')
|
||||||
|
if req_format is None:
|
||||||
|
req_format = 'best'
|
||||||
formats_to_download = []
|
formats_to_download = []
|
||||||
if req_format == 'best' or req_format is None:
|
|
||||||
formats_to_download = [formats[-1]]
|
|
||||||
elif req_format == 'worst':
|
|
||||||
formats_to_download = [formats[0]]
|
|
||||||
# The -1 is for supporting YoutubeIE
|
# The -1 is for supporting YoutubeIE
|
||||||
elif req_format in ('-1', 'all'):
|
if req_format in ('-1', 'all'):
|
||||||
formats_to_download = formats
|
formats_to_download = formats
|
||||||
else:
|
else:
|
||||||
# We can accept formats requestd in the format: 34/10/5, we pick
|
# We can accept formats requestd in the format: 34/5/best, we pick
|
||||||
# the first that is available, starting from left
|
# the first that is available, starting from left
|
||||||
req_formats = req_format.split('/')
|
req_formats = req_format.split('/')
|
||||||
for rf in req_formats:
|
for rf in req_formats:
|
||||||
matches = filter(lambda f:f['format_id'] == rf ,formats)
|
selected_format = self.select_format(rf, formats)
|
||||||
if matches:
|
if selected_format is not None:
|
||||||
formats_to_download = [matches[0]]
|
formats_to_download = [selected_format]
|
||||||
break
|
break
|
||||||
if not formats_to_download:
|
if not formats_to_download:
|
||||||
raise ExtractorError(u'requested format not available')
|
raise ExtractorError(u'requested format not available')
|
||||||
|
@ -754,16 +753,31 @@ class YoutubeDL(object):
|
||||||
with locked_file(fn, 'a', encoding='utf-8') as archive_file:
|
with locked_file(fn, 'a', encoding='utf-8') as archive_file:
|
||||||
archive_file.write(vid_id + u'\n')
|
archive_file.write(vid_id + u'\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def format_resolution(format):
|
||||||
|
if format.get('height') is not None:
|
||||||
|
if format.get('width') is not None:
|
||||||
|
res = u'%sx%s' % (format['width'], format['height'])
|
||||||
|
else:
|
||||||
|
res = u'%sp' % format['height']
|
||||||
|
else:
|
||||||
|
res = '???'
|
||||||
|
return res
|
||||||
|
|
||||||
def list_formats(self, info_dict):
|
def list_formats(self, info_dict):
|
||||||
formats_s = []
|
formats_s = []
|
||||||
for format in info_dict.get('formats', [info_dict]):
|
for format in info_dict.get('formats', [info_dict]):
|
||||||
formats_s.append("%s\t:\t%s\t[%s]" % (format['format_id'],
|
formats_s.append(u'%-15s: %-5s %-15s[%s]' % (
|
||||||
|
format['format_id'],
|
||||||
format['ext'],
|
format['ext'],
|
||||||
format.get('format', '???'),
|
format.get('format_note') or '-',
|
||||||
|
self.format_resolution(format),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if len(formats_s) != 1:
|
if len(formats_s) != 1:
|
||||||
formats_s[0] += ' (worst)'
|
formats_s[0] += ' (worst)'
|
||||||
formats_s[-1] += ' (best)'
|
formats_s[-1] += ' (best)'
|
||||||
formats_s = "\n".join(formats_s)
|
formats_s = "\n".join(formats_s)
|
||||||
self.to_screen(u"[info] Available formats for %s:\nformat code\textension\n%s" % (info_dict['id'], formats_s))
|
self.to_screen(u'[info] Available formats for %s:\n'
|
||||||
|
u'format code extension note resolution\n%s' % (
|
||||||
|
info_dict['id'], formats_s))
|
||||||
|
|
|
@ -174,12 +174,27 @@ class ArteTVPlus7IE(InfoExtractor):
|
||||||
# Some formats use the m3u8 protocol
|
# Some formats use the m3u8 protocol
|
||||||
formats = filter(lambda f: f.get('videoFormat') != 'M3U8', formats)
|
formats = filter(lambda f: f.get('videoFormat') != 'M3U8', formats)
|
||||||
# We order the formats by quality
|
# We order the formats by quality
|
||||||
formats = sorted(formats, key=lambda f: int(f.get('height',-1)))
|
formats = list(formats) # in python3 filter returns an iterator
|
||||||
|
if re.match(r'[A-Z]Q', formats[0]['quality']) is not None:
|
||||||
|
sort_key = lambda f: ['HQ', 'MQ', 'EQ', 'SQ'].index(f['quality'])
|
||||||
|
else:
|
||||||
|
sort_key = lambda f: int(f.get('height',-1))
|
||||||
|
formats = sorted(formats, key=sort_key)
|
||||||
# Prefer videos without subtitles in the same language
|
# Prefer videos without subtitles in the same language
|
||||||
formats = sorted(formats, key=lambda f: re.match(r'VO(F|A)-STM\1', f.get('versionCode', '')) is None)
|
formats = sorted(formats, key=lambda f: re.match(r'VO(F|A)-STM\1', f.get('versionCode', '')) is None)
|
||||||
# Pick the best quality
|
# Pick the best quality
|
||||||
def _format(format_info):
|
def _format(format_info):
|
||||||
|
quality = format_info['quality']
|
||||||
|
m_quality = re.match(r'\w*? - (\d*)p', quality)
|
||||||
|
if m_quality is not None:
|
||||||
|
quality = m_quality.group(1)
|
||||||
|
if format_info.get('versionCode') is not None:
|
||||||
|
format_id = u'%s-%s' % (quality, format_info['versionCode'])
|
||||||
|
else:
|
||||||
|
format_id = quality
|
||||||
info = {
|
info = {
|
||||||
|
'format_id': format_id,
|
||||||
|
'format_note': format_info.get('versionLibelle'),
|
||||||
'width': format_info.get('width'),
|
'width': format_info.get('width'),
|
||||||
'height': format_info.get('height'),
|
'height': format_info.get('height'),
|
||||||
}
|
}
|
||||||
|
@ -192,8 +207,6 @@ class ArteTVPlus7IE(InfoExtractor):
|
||||||
info['ext'] = determine_ext(info['url'])
|
info['ext'] = determine_ext(info['url'])
|
||||||
return info
|
return info
|
||||||
info_dict['formats'] = [_format(f) for f in formats]
|
info_dict['formats'] = [_format(f) for f in formats]
|
||||||
# TODO: Remove when #980 has been merged
|
|
||||||
info_dict.update(info_dict['formats'][-1])
|
|
||||||
|
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
|
@ -207,7 +220,7 @@ class ArteTVCreativeIE(ArteTVPlus7IE):
|
||||||
u'url': u'http://creative.arte.tv/de/magazin/agentur-amateur-corporate-design',
|
u'url': u'http://creative.arte.tv/de/magazin/agentur-amateur-corporate-design',
|
||||||
u'file': u'050489-002.mp4',
|
u'file': u'050489-002.mp4',
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u'title': u'Agentur Amateur #2 - Corporate Design',
|
u'title': u'Agentur Amateur / Agence Amateur #2 : Corporate Design',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,12 @@ class InfoExtractor(object):
|
||||||
* ext Will be calculated from url if missing
|
* ext Will be calculated from url if missing
|
||||||
* format A human-readable description of the format
|
* format A human-readable description of the format
|
||||||
("mp4 container with h264/opus").
|
("mp4 container with h264/opus").
|
||||||
Calculated from width and height if missing.
|
Calculated from the format_id, width, height
|
||||||
|
and format_note fields if missing.
|
||||||
* format_id A short description of the format
|
* format_id A short description of the format
|
||||||
("mp4_h264_opus" or "19")
|
("mp4_h264_opus" or "19")
|
||||||
|
* format_note Additional info about the format
|
||||||
|
("3D" or "DASH video")
|
||||||
* width Width of the video, if known
|
* width Width of the video, if known
|
||||||
* height Height of the video, if known
|
* height Height of the video, if known
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ class GooglePlusIE(InfoExtractor):
|
||||||
|
|
||||||
# Extract update date
|
# Extract update date
|
||||||
upload_date = self._html_search_regex(
|
upload_date = self._html_search_regex(
|
||||||
r'''(?x)<a.+?class="o-T-s\s[^"]+"\s+style="display:\s*none"\s*>
|
r'''(?x)<a.+?class="o-U-s\s[^"]+"\s+style="display:\s*none"\s*>
|
||||||
([0-9]{4}-[0-9]{2}-[0-9]{2})</a>''',
|
([0-9]{4}-[0-9]{2}-[0-9]{2})</a>''',
|
||||||
webpage, u'upload date', fatal=False)
|
webpage, u'upload date', fatal=False, flags=re.VERBOSE)
|
||||||
if upload_date:
|
if upload_date:
|
||||||
# Convert timestring to a format suitable for filename
|
# Convert timestring to a format suitable for filename
|
||||||
upload_date = datetime.datetime.strptime(upload_date, "%Y-%m-%d")
|
upload_date = datetime.datetime.strptime(upload_date, "%Y-%m-%d")
|
||||||
|
|
|
@ -19,7 +19,7 @@ class InternetVideoArchiveIE(InfoExtractor):
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u'title': u'SKYFALL',
|
u'title': u'SKYFALL',
|
||||||
u'description': u'In SKYFALL, Bond\'s loyalty to M is tested as her past comes back to haunt her. As MI6 comes under attack, 007 must track down and destroy the threat, no matter how personal the cost.',
|
u'description': u'In SKYFALL, Bond\'s loyalty to M is tested as her past comes back to haunt her. As MI6 comes under attack, 007 must track down and destroy the threat, no matter how personal the cost.',
|
||||||
u'duration': 156,
|
u'duration': 153,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class InternetVideoArchiveIE(InfoExtractor):
|
||||||
})
|
})
|
||||||
formats = sorted(formats, key=lambda f: f['bitrate'])
|
formats = sorted(formats, key=lambda f: f['bitrate'])
|
||||||
|
|
||||||
info = {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': item.find('title').text,
|
'title': item.find('title').text,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
@ -82,6 +82,3 @@ class InternetVideoArchiveIE(InfoExtractor):
|
||||||
'description': item.find('description').text,
|
'description': item.find('description').text,
|
||||||
'duration': int(attr['duration']),
|
'duration': int(attr['duration']),
|
||||||
}
|
}
|
||||||
# TODO: Remove when #980 has been merged
|
|
||||||
info.update(formats[-1])
|
|
||||||
return info
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ class NHLVideocenterIE(NHLBaseInfoExtractor):
|
||||||
r'{statusIndex:0,index:0,.*?id:(.*?),'],
|
r'{statusIndex:0,index:0,.*?id:(.*?),'],
|
||||||
webpage, u'category id')
|
webpage, u'category id')
|
||||||
playlist_title = self._html_search_regex(
|
playlist_title = self._html_search_regex(
|
||||||
r'\?catid=%s">(.*?)</a>' % cat_id,
|
r'tab0"[^>]*?>(.*?)</td>',
|
||||||
webpage, u'playlist title', flags=re.DOTALL)
|
webpage, u'playlist title', flags=re.DOTALL).lower().capitalize()
|
||||||
|
|
||||||
data = compat_urllib_parse.urlencode({
|
data = compat_urllib_parse.urlencode({
|
||||||
'cid': cat_id,
|
'cid': cat_id,
|
||||||
|
|
|
@ -16,7 +16,7 @@ class VideoDetectiveIE(InfoExtractor):
|
||||||
u'info_dict': {
|
u'info_dict': {
|
||||||
u'title': u'KICK-ASS 2',
|
u'title': u'KICK-ASS 2',
|
||||||
u'description': u'md5:65ba37ad619165afac7d432eaded6013',
|
u'description': u'md5:65ba37ad619165afac7d432eaded6013',
|
||||||
u'duration': 138,
|
u'duration': 135,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,46 +179,45 @@ class VimeoIE(InfoExtractor):
|
||||||
|
|
||||||
# Vimeo specific: extract video codec and quality information
|
# Vimeo specific: extract video codec and quality information
|
||||||
# First consider quality, then codecs, then take everything
|
# First consider quality, then codecs, then take everything
|
||||||
# TODO bind to format param
|
codecs = [('vp6', 'flv'), ('vp8', 'flv'), ('h264', 'mp4')]
|
||||||
codecs = [('h264', 'mp4'), ('vp8', 'flv'), ('vp6', 'flv')]
|
|
||||||
files = { 'hd': [], 'sd': [], 'other': []}
|
files = { 'hd': [], 'sd': [], 'other': []}
|
||||||
config_files = config["video"].get("files") or config["request"].get("files")
|
config_files = config["video"].get("files") or config["request"].get("files")
|
||||||
for codec_name, codec_extension in codecs:
|
for codec_name, codec_extension in codecs:
|
||||||
if codec_name in config_files:
|
for quality in config_files.get(codec_name, []):
|
||||||
if 'hd' in config_files[codec_name]:
|
format_id = '-'.join((codec_name, quality)).lower()
|
||||||
files['hd'].append((codec_name, codec_extension, 'hd'))
|
key = quality if quality in files else 'other'
|
||||||
elif 'sd' in config_files[codec_name]:
|
|
||||||
files['sd'].append((codec_name, codec_extension, 'sd'))
|
|
||||||
else:
|
|
||||||
files['other'].append((codec_name, codec_extension, config_files[codec_name][0]))
|
|
||||||
|
|
||||||
for quality in ('hd', 'sd', 'other'):
|
|
||||||
if len(files[quality]) > 0:
|
|
||||||
video_quality = files[quality][0][2]
|
|
||||||
video_codec = files[quality][0][0]
|
|
||||||
video_extension = files[quality][0][1]
|
|
||||||
self.to_screen(u'%s: Downloading %s file at %s quality' % (video_id, video_codec.upper(), video_quality))
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise ExtractorError(u'No known codec found')
|
|
||||||
|
|
||||||
video_url = None
|
video_url = None
|
||||||
if isinstance(config_files[video_codec], dict):
|
if isinstance(config_files[codec_name], dict):
|
||||||
video_url = config_files[video_codec][video_quality].get("url")
|
file_info = config_files[codec_name][quality]
|
||||||
|
video_url = file_info.get('url')
|
||||||
|
else:
|
||||||
|
file_info = {}
|
||||||
if video_url is None:
|
if video_url is None:
|
||||||
video_url = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location=" \
|
video_url = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location=" \
|
||||||
%(video_id, sig, timestamp, video_quality, video_codec.upper())
|
%(video_id, sig, timestamp, quality, codec_name.upper())
|
||||||
|
|
||||||
|
files[key].append({
|
||||||
|
'ext': codec_extension,
|
||||||
|
'url': video_url,
|
||||||
|
'format_id': format_id,
|
||||||
|
'width': file_info.get('width'),
|
||||||
|
'height': file_info.get('height'),
|
||||||
|
})
|
||||||
|
formats = []
|
||||||
|
for key in ('other', 'sd', 'hd'):
|
||||||
|
formats += files[key]
|
||||||
|
if len(formats) == 0:
|
||||||
|
raise ExtractorError(u'No known codec found')
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
|
||||||
'uploader': video_uploader,
|
'uploader': video_uploader,
|
||||||
'uploader_id': video_uploader_id,
|
'uploader_id': video_uploader_id,
|
||||||
'upload_date': video_upload_date,
|
'upload_date': video_upload_date,
|
||||||
'title': video_title,
|
'title': video_title,
|
||||||
'ext': video_extension,
|
|
||||||
'thumbnail': video_thumbnail,
|
'thumbnail': video_thumbnail,
|
||||||
'description': video_description,
|
'description': video_description,
|
||||||
|
'formats': formats,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1150,7 +1150,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
||||||
list_page = self._download_webpage(list_url, video_id)
|
list_page = self._download_webpage(list_url, video_id)
|
||||||
caption_list = xml.etree.ElementTree.fromstring(list_page.encode('utf-8'))
|
caption_list = xml.etree.ElementTree.fromstring(list_page.encode('utf-8'))
|
||||||
original_lang_node = caption_list.find('track')
|
original_lang_node = caption_list.find('track')
|
||||||
if not original_lang_node or original_lang_node.attrib.get('kind') != 'asr' :
|
if original_lang_node is None or original_lang_node.attrib.get('kind') != 'asr' :
|
||||||
self._downloader.report_warning(u'Video doesn\'t have automatic captions')
|
self._downloader.report_warning(u'Video doesn\'t have automatic captions')
|
||||||
return {}
|
return {}
|
||||||
original_lang = original_lang_node.attrib['lang_code']
|
original_lang = original_lang_node.attrib['lang_code']
|
||||||
|
|
Loading…
Reference in a new issue