X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2F__init__.py;h=dfcaccafa4afeddb2df5161180c97a7559f4d0a8;hb=95464f14d11d9441b48a55c6b9d96750f9a260fd;hp=ce754ffd30ac0b7373dd22443373ad506b500b81;hpb=81df121dd3497a9a00fc76a58d667b5afef3b8d1;p=youtube-dl diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index ce754ffd3..dfcaccafa 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -25,6 +25,7 @@ __authors__ = ( 'Jeff Crouse', 'Osama Khalid', 'Michael Walter', + 'M. Yasoob Ullah Khalid', ) __license__ = 'Public Domain' @@ -146,6 +147,7 @@ def parseOpts(overrideArguments=None): general.add_option('--list-extractors', action='store_true', dest='list_extractors', help='List all supported extractors and the URLs they would handle', default=False) + general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL') general.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP) selection.add_option('--playlist-start', @@ -236,9 +238,9 @@ def parseOpts(overrideArguments=None): help='print downloaded pages to debug problems(very verbose)') filesystem.add_option('-t', '--title', - action='store_true', dest='usetitle', help='use title in file name', default=False) + action='store_true', dest='usetitle', help='use title in file name (default)', default=False) filesystem.add_option('--id', - action='store_true', dest='useid', help='use video ID in file name', default=False) + action='store_true', dest='useid', help='use only video ID in file name', default=False) filesystem.add_option('-l', '--literal', action='store_true', dest='usetitle', help='[deprecated] alias of --title', default=False) filesystem.add_option('-A', '--auto-number', @@ -283,6 +285,9 @@ def parseOpts(overrideArguments=None): filesystem.add_option('--write-info-json', action='store_true', dest='writeinfojson', help='write video metadata to a .info.json file', default=False) + filesystem.add_option('--write-thumbnail', + action='store_true', dest='writethumbnail', + help='write thumbnail image to disk', default=False) postproc.add_option('-x', '--extract-audio', action='store_true', dest='extractaudio', default=False, @@ -376,8 +381,16 @@ def _real_main(argv=None): # General configuration cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar) - proxy_handler = compat_urllib_request.ProxyHandler() - opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler()) + if opts.proxy: + proxies = {'http': opts.proxy, 'https': opts.proxy} + else: + proxies = compat_urllib_request.getproxies() + # Set HTTPS proxy to HTTP one if given (https://github.com/rg3/youtube-dl/issues/805) + if 'http' in proxies and 'https' not in proxies: + proxies['https'] = proxies['http'] + proxy_handler = compat_urllib_request.ProxyHandler(proxies) + https_handler = compat_urllib_request.HTTPSHandler() + opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, YoutubeDLHandler()) compat_urllib_request.install_opener(opener) socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words) @@ -466,7 +479,7 @@ def _real_main(argv=None): 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') + or u'%(title)s-%(id)s.%(ext)s') # File downloader fd = FileDownloader({ @@ -505,6 +518,7 @@ def _real_main(argv=None): 'updatetime': opts.updatetime, 'writedescription': opts.writedescription, 'writeinfojson': opts.writeinfojson, + 'writethumbnail': opts.writethumbnail, 'writesubtitles': opts.writesubtitles, 'onlysubtitles': opts.onlysubtitles, 'allsubtitles': opts.allsubtitles, @@ -521,7 +535,7 @@ def _real_main(argv=None): 'keepvideo': opts.keepvideo, 'min_filesize': opts.min_filesize, 'max_filesize': opts.max_filesize, - 'daterange': date + 'daterange': date, }) if opts.verbose: