[movefiles] Fix compatibility with python2
:ci skip dl
This commit is contained in:
parent
4d608b522f
commit
8a0b932258
3 changed files with 9 additions and 7 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -58,6 +58,10 @@ youtube-dlc
|
||||||
*.ogg
|
*.ogg
|
||||||
*.opus
|
*.opus
|
||||||
*.info.json
|
*.info.json
|
||||||
|
*.live_chat.json
|
||||||
|
*.jpg
|
||||||
|
*.png
|
||||||
|
*.webp
|
||||||
*.annotations.xml
|
*.annotations.xml
|
||||||
*.description
|
*.description
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ import shutil
|
||||||
|
|
||||||
from .common import PostProcessor
|
from .common import PostProcessor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
decodeFilename,
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
make_dir,
|
make_dir,
|
||||||
PostProcessingError,
|
PostProcessingError,
|
||||||
)
|
)
|
||||||
from ..compat import compat_str
|
|
||||||
|
|
||||||
|
|
||||||
class MoveFilesAfterDownloadPP(PostProcessor):
|
class MoveFilesAfterDownloadPP(PostProcessor):
|
||||||
|
@ -26,12 +26,12 @@ class MoveFilesAfterDownloadPP(PostProcessor):
|
||||||
finaldir = info.get('__finaldir', dl_path)
|
finaldir = info.get('__finaldir', dl_path)
|
||||||
finalpath = os.path.join(finaldir, dl_name)
|
finalpath = os.path.join(finaldir, dl_name)
|
||||||
self.files_to_move.update(info['__files_to_move'])
|
self.files_to_move.update(info['__files_to_move'])
|
||||||
self.files_to_move[info['filepath']] = finalpath
|
self.files_to_move[info['filepath']] = decodeFilename(finalpath)
|
||||||
|
|
||||||
|
make_newfilename = lambda old: decodeFilename(os.path.join(finaldir, os.path.basename(encodeFilename(old))))
|
||||||
for oldfile, newfile in self.files_to_move.items():
|
for oldfile, newfile in self.files_to_move.items():
|
||||||
if not newfile:
|
if not newfile:
|
||||||
newfile = os.path.join(finaldir, os.path.basename(encodeFilename(oldfile)))
|
newfile = make_newfilename(oldfile)
|
||||||
oldfile, newfile = compat_str(oldfile), compat_str(newfile)
|
|
||||||
if os.path.abspath(encodeFilename(oldfile)) == os.path.abspath(encodeFilename(newfile)):
|
if os.path.abspath(encodeFilename(oldfile)) == os.path.abspath(encodeFilename(newfile)):
|
||||||
continue
|
continue
|
||||||
if not os.path.exists(encodeFilename(oldfile)):
|
if not os.path.exists(encodeFilename(oldfile)):
|
||||||
|
@ -50,5 +50,5 @@ class MoveFilesAfterDownloadPP(PostProcessor):
|
||||||
self.to_screen('Moving file "%s" to "%s"' % (oldfile, newfile))
|
self.to_screen('Moving file "%s" to "%s"' % (oldfile, newfile))
|
||||||
shutil.move(oldfile, newfile) # os.rename cannot move between volumes
|
shutil.move(oldfile, newfile) # os.rename cannot move between volumes
|
||||||
|
|
||||||
info['filepath'] = compat_str(finalpath)
|
info['filepath'] = finalpath
|
||||||
return [], info
|
return [], info
|
||||||
|
|
|
@ -4690,9 +4690,7 @@ def cli_configuration_args(params, arg_name, key, default=[], exe=None): # retu
|
||||||
return default, False
|
return default, False
|
||||||
assert isinstance(argdict, dict)
|
assert isinstance(argdict, dict)
|
||||||
|
|
||||||
assert isinstance(key, compat_str)
|
|
||||||
key = key.lower()
|
key = key.lower()
|
||||||
|
|
||||||
args = exe_args = None
|
args = exe_args = None
|
||||||
if exe is not None:
|
if exe is not None:
|
||||||
assert isinstance(exe, compat_str)
|
assert isinstance(exe, compat_str)
|
||||||
|
|
Loading…
Reference in a new issue