forcetitle: Force printing title.
simulate: Do not download the video files.
format: Video format code.
+ format_limit: Highest quality format to try.
outtmpl: Template for output names.
ignoreerrors: Do not stop on download errors.
ratelimit: Download speed limit, in bytes/sec.
class YoutubeIE(InfoExtractor):
"""Information extractor for youtube.com."""
- _VALID_URL = r'^((?:http://)?(?:\w+\.)?youtube\.com/(?:(?:v/)|(?:(?:watch(?:\.php)?)?[\?#](?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$'
+ _VALID_URL = r'^((?:http://)?(?:youtu\.be/|(?:\w+\.)?youtube\.com/(?:(?:v/)|(?:(?:watch(?:_popup)?(?:\.php)?)?[\?#](?:.+&)?v=))))?([0-9A-Za-z_-]+)(?(1).+)?$'
_LANG_URL = r'http://uk.youtube.com/?hl=en&persist_hl=1&gl=US&persist_gl=1&opt_out_ackd=1'
_LOGIN_URL = 'http://www.youtube.com/signup?next=/&gl=US&hl=en'
_AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
'18': 'mp4',
'22': 'mp4',
'37': 'mp4',
- '38': 'video',
+ '38': 'video', # You actually don't know if this will be MOV, AVI or whatever
'43': 'webm',
'45': 'webm',
}
params = self._downloader.params
format_param = params.get('format', None)
if format_param == '0':
+ format_limit = params.get('format_limit', None)
+ if format_limit is not None:
+ try:
+ # Start at a different format if the user has limited the maximum quality
+ quality_index = self._available_formats.index(format_limit)
+ except ValueError:
+ pass
format_param = self._available_formats[quality_index]
best_quality = True
elif format_param == '-1':
return
# Attempt to extract SWF player URL
- mobj = re.search(r'swfConfig.*"(http://.*?watch-.*?\.swf)"', video_webpage)
+ mobj = re.search(r'swfConfig.*"(http://.*?watch.*?-.*?\.swf)"', video_webpage)
if mobj is not None:
player_url = mobj.group(1)
else:
action='store_const', dest='format', help='alias for -f 22', const='22')
video_format.add_option('--all-formats',
action='store_const', dest='format', help='download all available video formats', const='-1')
+ video_format.add_option('--max-quality',
+ action='store', dest='format_limit', metavar='FORMAT', help='highest quality format limit for -b')
parser.add_option_group(video_format)
verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options')
'forcedescription': opts.getdescription,
'simulate': (opts.simulate or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription),
'format': opts.format,
+ 'format_limit': opts.format_limit,
'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(preferredencoding()))
or (opts.format == '-1' and opts.usetitle and u'%(stitle)s-%(id)s-%(format)s.%(ext)s')
or (opts.format == '-1' and opts.useliteral and u'%(title)s-%(id)s-%(format)s.%(ext)s')