mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-19 01:45:13 +00:00
Only catch UnavailableFormatError in call to process_info
This commit is contained in:
parent
cbfff4db63
commit
968aa88438
1 changed files with 42 additions and 43 deletions
85
youtube-dl
85
youtube-dl
|
@ -288,7 +288,6 @@ class FileDownloader(object):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
template_dict = dict(info_dict)
|
template_dict = dict(info_dict)
|
||||||
template_dict['epoch'] = unicode(long(time.time()))
|
template_dict['epoch'] = unicode(long(time.time()))
|
||||||
|
@ -621,53 +620,53 @@ class YoutubeIE(InfoExtractor):
|
||||||
best_quality = True
|
best_quality = True
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
# Extension
|
||||||
|
video_extension = self._video_extensions.get(format_param, 'flv')
|
||||||
|
|
||||||
|
# Normalize URL, including format
|
||||||
|
normalized_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
|
||||||
|
if format_param is not None:
|
||||||
|
normalized_url = '%s&fmt=%s' % (normalized_url, format_param)
|
||||||
|
request = urllib2.Request(normalized_url, None, std_headers)
|
||||||
try:
|
try:
|
||||||
# Extension
|
self.report_webpage_download(video_id)
|
||||||
video_extension = self._video_extensions.get(format_param, 'flv')
|
video_webpage = urllib2.urlopen(request).read()
|
||||||
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % str(err))
|
||||||
|
return
|
||||||
|
self.report_information_extraction(video_id)
|
||||||
|
|
||||||
|
# "t" param
|
||||||
|
mobj = re.search(r', "t": "([^"]+)"', video_webpage)
|
||||||
|
if mobj is None:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to extract "t" parameter')
|
||||||
|
return
|
||||||
|
video_real_url = 'http://www.youtube.com/get_video?video_id=%s&t=%s&el=detailpage&ps=' % (video_id, mobj.group(1))
|
||||||
|
if format_param is not None:
|
||||||
|
video_real_url = '%s&fmt=%s' % (video_real_url, format_param)
|
||||||
|
self.report_video_url(video_id, video_real_url)
|
||||||
|
|
||||||
# Normalize URL, including format
|
# uploader
|
||||||
normalized_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
|
mobj = re.search(r"var watchUsername = '([^']+)';", video_webpage)
|
||||||
if format_param is not None:
|
if mobj is None:
|
||||||
normalized_url = '%s&fmt=%s' % (normalized_url, format_param)
|
self._downloader.trouble(u'ERROR: unable to extract uploader nickname')
|
||||||
request = urllib2.Request(normalized_url, None, std_headers)
|
return
|
||||||
try:
|
video_uploader = mobj.group(1)
|
||||||
self.report_webpage_download(video_id)
|
|
||||||
video_webpage = urllib2.urlopen(request).read()
|
|
||||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
|
||||||
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % str(err))
|
|
||||||
return
|
|
||||||
self.report_information_extraction(video_id)
|
|
||||||
|
|
||||||
# "t" param
|
|
||||||
mobj = re.search(r', "t": "([^"]+)"', video_webpage)
|
|
||||||
if mobj is None:
|
|
||||||
self._downloader.trouble(u'ERROR: unable to extract "t" parameter')
|
|
||||||
return
|
|
||||||
video_real_url = 'http://www.youtube.com/get_video?video_id=%s&t=%s&el=detailpage&ps=' % (video_id, mobj.group(1))
|
|
||||||
if format_param is not None:
|
|
||||||
video_real_url = '%s&fmt=%s' % (video_real_url, format_param)
|
|
||||||
self.report_video_url(video_id, video_real_url)
|
|
||||||
|
|
||||||
# uploader
|
# title
|
||||||
mobj = re.search(r"var watchUsername = '([^']+)';", video_webpage)
|
mobj = re.search(r'(?im)<title>YouTube - ([^<]*)</title>', video_webpage)
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract uploader nickname')
|
self._downloader.trouble(u'ERROR: unable to extract video title')
|
||||||
return
|
return
|
||||||
video_uploader = mobj.group(1)
|
video_title = mobj.group(1).decode('utf-8')
|
||||||
|
video_title = re.sub(ur'(?u)&(.+?);', self.htmlentity_transform, video_title)
|
||||||
|
video_title = video_title.replace(os.sep, u'%')
|
||||||
|
|
||||||
# title
|
# simplified title
|
||||||
mobj = re.search(r'(?im)<title>YouTube - ([^<]*)</title>', video_webpage)
|
simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', video_title)
|
||||||
if mobj is None:
|
simple_title = simple_title.strip(ur'_')
|
||||||
self._downloader.trouble(u'ERROR: unable to extract video title')
|
|
||||||
return
|
|
||||||
video_title = mobj.group(1).decode('utf-8')
|
|
||||||
video_title = re.sub(ur'(?u)&(.+?);', self.htmlentity_transform, video_title)
|
|
||||||
video_title = video_title.replace(os.sep, u'%')
|
|
||||||
|
|
||||||
# simplified title
|
|
||||||
simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', video_title)
|
|
||||||
simple_title = simple_title.strip(ur'_')
|
|
||||||
|
|
||||||
|
try:
|
||||||
# Process video information
|
# Process video information
|
||||||
self._downloader.process_info({
|
self._downloader.process_info({
|
||||||
'id': video_id.decode('utf-8'),
|
'id': video_id.decode('utf-8'),
|
||||||
|
|
Loading…
Reference in a new issue