Some consistency changes and ghost-file bugfix after discussion with rg3

This commit is contained in:
dannycolligan 2009-04-28 14:39:23 -07:00 committed by Ricardo Garcia
parent 2740c509b3
commit 42bcd27d3b

View file

@ -284,11 +284,8 @@ class FileDownloader(object):
self._do_download(outstream, info_dict['url']) self._do_download(outstream, info_dict['url'])
outstream.close() outstream.close()
except (OSError, IOError), err: except (OSError, IOError), err:
if info_dict['best_quality']: os.remove(filename)
raise UnavailableFormatError raise UnavailableFormatError
else:
self.trouble('ERROR: unable to write video data: %s' % str(err))
return
except (urllib2.URLError, httplib.HTTPException, socket.error), err: except (urllib2.URLError, httplib.HTTPException, socket.error), err:
self.trouble('ERROR: unable to download video data: %s' % str(err)) self.trouble('ERROR: unable to download video data: %s' % str(err))
return return
@ -643,12 +640,12 @@ class YoutubeIE(InfoExtractor):
'title': video_title, 'title': video_title,
'stitle': simple_title, 'stitle': simple_title,
'ext': video_extension.decode('utf-8'), 'ext': video_extension.decode('utf-8'),
'best_quality': best_quality,
}) })
return return
except UnavailableFormatError: except UnavailableFormatError, err:
if best_quality:
if quality_index == len(self._available_formats) - 1: if quality_index == len(self._available_formats) - 1:
# I don't ever expect this to happen # I don't ever expect this to happen
self._downloader.trouble(u'ERROR: no known formats available for video') self._downloader.trouble(u'ERROR: no known formats available for video')
@ -658,6 +655,10 @@ class YoutubeIE(InfoExtractor):
quality_index += 1 quality_index += 1
format_param = self._available_formats[quality_index] format_param = self._available_formats[quality_index]
continue continue
else:
self._downloader.trouble('ERROR: format not available for video')
return
class MetacafeIE(InfoExtractor): class MetacafeIE(InfoExtractor):
"""Information Extractor for metacafe.com.""" """Information Extractor for metacafe.com."""
@ -769,6 +770,7 @@ class MetacafeIE(InfoExtractor):
return return
video_uploader = mobj.group(1) video_uploader = mobj.group(1)
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'),
@ -777,8 +779,9 @@ class MetacafeIE(InfoExtractor):
'title': video_title, 'title': video_title,
'stitle': simple_title, 'stitle': simple_title,
'ext': video_extension.decode('utf-8'), 'ext': video_extension.decode('utf-8'),
'best_quality': False, # TODO
}) })
except UnavailableFormatError:
self._downloader.trouble(u'ERROR: format not available for video')
class YoutubeSearchIE(InfoExtractor): class YoutubeSearchIE(InfoExtractor):
@ -1079,8 +1082,13 @@ if __name__ == '__main__':
if numeric_limit is None: if numeric_limit is None:
parser.error(u'invalid rate limit specified') parser.error(u'invalid rate limit specified')
opts.ratelimit = numeric_limit opts.ratelimit = numeric_limit
if len(opts.format) > 1: if opts.format is not None and len(opts.format) > 1:
parser.error(u'pass at most one of the video format option flags (-f, -b, -m, -d)') parser.error(u'pass at most one of the video format option flags (-f, -b, -m, -d)')
if opts.format is None:
real_format = None
else:
real_format = opts.format[0]
# Information extractors # Information extractors
youtube_ie = YoutubeIE() youtube_ie = YoutubeIE()
@ -1097,7 +1105,7 @@ if __name__ == '__main__':
'forceurl': opts.geturl, 'forceurl': opts.geturl,
'forcetitle': opts.gettitle, 'forcetitle': opts.gettitle,
'simulate': (opts.simulate or opts.geturl or opts.gettitle), 'simulate': (opts.simulate or opts.geturl or opts.gettitle),
'format': opts.format[0], 'format': real_format,
'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(locale.getpreferredencoding())) 'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(locale.getpreferredencoding()))
or (opts.usetitle and u'%(stitle)s-%(id)s.%(ext)s') or (opts.usetitle and u'%(stitle)s-%(id)s.%(ext)s')
or (opts.useliteral and u'%(title)s-%(id)s.%(ext)s') or (opts.useliteral and u'%(title)s-%(id)s.%(ext)s')