diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2012-12-15 17:44:48 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2012-12-15 17:44:48 +0100 |
commit | 5cb9c3129b177c7b4a9498f2f3f3e73993520d41 (patch) | |
tree | 740e7bfbdb934d12daa6f36d8b88bf993d519d30 | |
parent | 4cc3d0742663c92ef5cf89927edee4300666ea69 (diff) |
restrict sys.argv craziness to Python 2 (Fixes #591)
-rw-r--r-- | youtube_dl/__init__.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index b6ee2e119..ce4e67848 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -504,6 +504,17 @@ 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) + 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, @@ -521,14 +532,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, |