X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2F__init__.py;h=d044797f0b55080eeb600da844135ae768eede8e;hb=99b0a1292b6ceccca576c8555e03bc13fb8e4bdd;hp=d7e1a91ada0ce29df8c2f0dca23d93a8e4d43acc;hpb=d050de77f94a5dc9071c0b459ba62cb09c6696c4;p=youtube-dl diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index d7e1a91ad..d044797f0 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -20,6 +20,7 @@ __authors__ = ( 'shizeeg', 'Filippo Valsorda', 'Christian Albrecht', + 'Dave Vasilevsky', ) __license__ = 'Public Domain' @@ -306,7 +307,7 @@ def parseOpts(): action='store_true', dest='autonumber', help='number downloaded files starting from 00000', default=False) filesystem.add_option('-o', '--output', - dest='outtmpl', metavar='TEMPLATE', help='output filename template. Use %(title)s to get the title, %(uploader)s for the uploader name, %(autonumber)s to get an automatically incremented number, %(ext)s for the filename extension, %(upload_date)s for the upload date (YYYYMMDD), %(extractor)s for the provider (youtube, metacafe, etc), %(id)s for the video id and %% for a literal percent. Use - to output to stdout. Can also be used to download to a different directory, for example with -o \'/my/downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s\' .') + dest='outtmpl', metavar='TEMPLATE', help='output filename template. Use %(title)s to get the title, %(uploader)s for the uploader name, %(uploader_id)s for the uploader nickname if different, %(autonumber)s to get an automatically incremented number, %(ext)s for the filename extension, %(upload_date)s for the upload date (YYYYMMDD), %(extractor)s for the provider (youtube, metacafe, etc), %(id)s for the video id and %% for a literal percent. Use - to output to stdout. Can also be used to download to a different directory, for example with -o \'/my/downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s\' .') filesystem.add_option('--restrict-filenames', action='store_true', dest='restrictfilenames', help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames', default=False) @@ -342,6 +343,8 @@ def parseOpts(): help='ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)') postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False, help='keeps the video file on disk after the post-processing; the video is erased by default') + postproc.add_option('--no-post-overwrites', action='store_true', dest='nopostoverwrites', default=False, + help='do not overwrite post-processed files; the post-processed files are overwritten by default') parser.add_option_group(general) @@ -374,7 +377,6 @@ def gen_extractors(): YoutubeIE(), MetacafeIE(), DailymotionIE(), - GoogleIE(), GoogleSearchIE(), PhotobucketIE(), YahooIE(), @@ -398,6 +400,9 @@ def gen_extractors(): XNXXIE(), GooglePlusIE(), ArteTvIE(), + NBAIE(), + JustinTVIE(), + FunnyOrDieIE(), GenericIE() ] @@ -451,8 +456,8 @@ def _real_main(): if opts.list_extractors: for ie in extractors: print(ie.IE_NAME + (' (CURRENTLY BROKEN)' if not ie._WORKING else '')) - matchedUrls = filter(lambda url: ie.suitable(url), all_urls) - all_urls = filter(lambda url: url not in matchedUrls, all_urls) + matchedUrls = [url for url in all_urls if ie.suitable(url)] + all_urls = [url for url in all_urls if url not in matchedUrls] for mu in matchedUrls: print(u' ' + mu) sys.exit(0) @@ -503,6 +508,18 @@ def _real_main(): if not opts.audioquality.isdigit(): parser.error(u'invalid audio quality specified') + if sys.version_info < (3,): + # In Python 2, sys.argv is a bytestring (also note http://bugs.python.org/issue2128 for Windows systems) + if opts.outtmpl is not None: + opts.outtmpl = opts.outtmpl.decode(preferredencoding()) + outtmpl =((opts.outtmpl is not None and opts.outtmpl) + or (opts.format == '-1' and opts.usetitle and u'%(title)s-%(id)s-%(format)s.%(ext)s') + or (opts.format == '-1' and u'%(id)s-%(format)s.%(ext)s') + or (opts.usetitle and opts.autonumber and u'%(autonumber)s-%(title)s-%(id)s.%(ext)s') + or (opts.usetitle and u'%(title)s-%(id)s.%(ext)s') + or (opts.useid and u'%(id)s.%(ext)s') + or (opts.autonumber and u'%(autonumber)s-%(id)s.%(ext)s') + or u'%(id)s.%(ext)s') # File downloader fd = FileDownloader({ 'usenetrc': opts.usenetrc, @@ -520,14 +537,7 @@ def _real_main(): 'format': opts.format, 'format_limit': opts.format_limit, 'listformats': opts.listformats, - 'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(preferredencoding())) - or (opts.format == '-1' and opts.usetitle and u'%(title)s-%(id)s-%(format)s.%(ext)s') - or (opts.format == '-1' and u'%(id)s-%(format)s.%(ext)s') - or (opts.usetitle and opts.autonumber and u'%(autonumber)s-%(title)s-%(id)s.%(ext)s') - or (opts.usetitle and u'%(title)s-%(id)s.%(ext)s') - or (opts.useid and u'%(id)s.%(ext)s') - or (opts.autonumber and u'%(autonumber)s-%(id)s.%(ext)s') - or u'%(id)s.%(ext)s'), + 'outtmpl': outtmpl, 'restrictfilenames': opts.restrictfilenames, 'ignoreerrors': opts.ignoreerrors, 'ratelimit': opts.ratelimit, @@ -563,7 +573,7 @@ def _real_main(): # PostProcessors if opts.extractaudio: - fd.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, keepvideo=opts.keepvideo)) + fd.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, keepvideo=opts.keepvideo, nopostoverwrites=opts.nopostoverwrites)) # Update version if opts.update_self: