mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-10-31 22:55:26 +00:00
restrict sys.argv craziness to Python 2 (Fixes #591)
This commit is contained in:
parent
4cc3d07426
commit
5cb9c3129b
1 changed files with 12 additions and 8 deletions
|
@ -504,6 +504,17 @@ def _real_main():
|
||||||
if not opts.audioquality.isdigit():
|
if not opts.audioquality.isdigit():
|
||||||
parser.error(u'invalid audio quality specified')
|
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
|
# File downloader
|
||||||
fd = FileDownloader({
|
fd = FileDownloader({
|
||||||
'usenetrc': opts.usenetrc,
|
'usenetrc': opts.usenetrc,
|
||||||
|
@ -521,14 +532,7 @@ def _real_main():
|
||||||
'format': opts.format,
|
'format': opts.format,
|
||||||
'format_limit': opts.format_limit,
|
'format_limit': opts.format_limit,
|
||||||
'listformats': opts.listformats,
|
'listformats': opts.listformats,
|
||||||
'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(preferredencoding()))
|
'outtmpl': 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'),
|
|
||||||
'restrictfilenames': opts.restrictfilenames,
|
'restrictfilenames': opts.restrictfilenames,
|
||||||
'ignoreerrors': opts.ignoreerrors,
|
'ignoreerrors': opts.ignoreerrors,
|
||||||
'ratelimit': opts.ratelimit,
|
'ratelimit': opts.ratelimit,
|
||||||
|
|
Loading…
Reference in a new issue