mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-13 14:37:43 +01:00
Restore proper support for webm formats (fixes issue #166)
This commit is contained in:
parent
8190e3631b
commit
2e3a32e4ac
34
youtube-dl
34
youtube-dl
@ -879,7 +879,36 @@ class YoutubeIE(InfoExtractor):
|
|||||||
video_description = mobj.group(1)
|
video_description = mobj.group(1)
|
||||||
|
|
||||||
# Decide which formats to download
|
# Decide which formats to download
|
||||||
if 'fmt_url_map' in video_info:
|
requested_format = self._downloader.params.get('format', None)
|
||||||
|
|
||||||
|
if requested_format in ["43", "45"]: # webm formats
|
||||||
|
# Join the HTML5 beta
|
||||||
|
html5form = { "enable_html5": "true" }
|
||||||
|
request = urllib2.Request('http://www.youtube.com/html5', urllib.urlencode(html5form), std_headers)
|
||||||
|
try:
|
||||||
|
self._downloader.to_stdout(u'[youtube] Joining the HTML5 Beta')
|
||||||
|
urllib2.urlopen(request).read()
|
||||||
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to join the HTML5 Beta: %s' % str(err))
|
||||||
|
return
|
||||||
|
|
||||||
|
# Request the video webpage with webm enabled
|
||||||
|
request = urllib2.Request('http://www.youtube.com/watch?v=%s&webm=1' % video_id, None, std_headers)
|
||||||
|
try:
|
||||||
|
self._downloader.to_stdout(u'[youtube] Requesting HTML5 video webpage')
|
||||||
|
video_webpage = urllib2.urlopen(request).read()
|
||||||
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to get the HTML5 video webpage: %s' % str(err))
|
||||||
|
return
|
||||||
|
|
||||||
|
# Find the URL for the requested format
|
||||||
|
mobj = re.search(ur'setAvailableFormat\("(.*?)".*?"%s"\);' % requested_format, video_webpage)
|
||||||
|
if mobj is None:
|
||||||
|
self._downloader.trouble(u'ERROR: format not available for video')
|
||||||
|
return
|
||||||
|
video_url_list = [(requested_format, mobj.group(1))]
|
||||||
|
|
||||||
|
elif 'fmt_url_map' in video_info:
|
||||||
url_map = dict(tuple(pair.split('|')) for pair in video_info['fmt_url_map'][0].split(','))
|
url_map = dict(tuple(pair.split('|')) for pair in video_info['fmt_url_map'][0].split(','))
|
||||||
format_limit = self._downloader.params.get('format_limit', None)
|
format_limit = self._downloader.params.get('format_limit', None)
|
||||||
if format_limit is not None and format_limit in self._available_formats:
|
if format_limit is not None and format_limit in self._available_formats:
|
||||||
@ -890,7 +919,6 @@ class YoutubeIE(InfoExtractor):
|
|||||||
if len(existing_formats) == 0:
|
if len(existing_formats) == 0:
|
||||||
self._downloader.trouble(u'ERROR: no known formats available for video')
|
self._downloader.trouble(u'ERROR: no known formats available for video')
|
||||||
return
|
return
|
||||||
requested_format = self._downloader.params.get('format', None)
|
|
||||||
if requested_format is None:
|
if requested_format is None:
|
||||||
video_url_list = [(existing_formats[0], url_map[existing_formats[0]])] # Best quality
|
video_url_list = [(existing_formats[0], url_map[existing_formats[0]])] # Best quality
|
||||||
elif requested_format == '-1':
|
elif requested_format == '-1':
|
||||||
@ -900,9 +928,11 @@ class YoutubeIE(InfoExtractor):
|
|||||||
self._downloader.trouble(u'ERROR: format not available for video')
|
self._downloader.trouble(u'ERROR: format not available for video')
|
||||||
return
|
return
|
||||||
video_url_list = [(requested_format, url_map[requested_format])] # Specific format
|
video_url_list = [(requested_format, url_map[requested_format])] # Specific format
|
||||||
|
|
||||||
elif 'conn' in video_info and video_info['conn'][0].startswith('rtmp'):
|
elif 'conn' in video_info and video_info['conn'][0].startswith('rtmp'):
|
||||||
self.report_rtmp_download()
|
self.report_rtmp_download()
|
||||||
video_url_list = [(None, video_info['conn'][0])]
|
video_url_list = [(None, video_info['conn'][0])]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._downloader.trouble(u'ERROR: no fmt_url_map or conn information found in video info')
|
self._downloader.trouble(u'ERROR: no fmt_url_map or conn information found in video info')
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user