]> jfr.im git - yt-dlp.git/commitdiff
[movefiles] Fix compatibility with python2
authorpukkandan <redacted>
Sun, 7 Feb 2021 11:17:48 +0000 (16:47 +0530)
committerpukkandan <redacted>
Sun, 7 Feb 2021 12:11:41 +0000 (17:41 +0530)
:ci skip dl

.gitignore
youtube_dlc/postprocessor/movefilesafterdownload.py
youtube_dlc/utils.py

index c48bdb89cc04e7b14d09dcdc701d21cab89a2419..73288053d949aabf20b7ee7ae09d9c1ad3f3b19a 100644 (file)
@@ -58,6 +58,10 @@ youtube-dlc
 *.ogg
 *.opus
 *.info.json
+*.live_chat.json
+*.jpg
+*.png
+*.webp
 *.annotations.xml
 *.description
 
index 7f34ac5c5ec8c1d5d1baf6000b85166986ca8205..fa61317ed832fbdc16ba36d77335fa798b62d9f8 100644 (file)
@@ -4,11 +4,11 @@
 
 from .common import PostProcessor
 from ..utils import (
+    decodeFilename,
     encodeFilename,
     make_dir,
     PostProcessingError,
 )
-from ..compat import compat_str
 
 
 class MoveFilesAfterDownloadPP(PostProcessor):
@@ -26,12 +26,12 @@ def run(self, info):
         finaldir = info.get('__finaldir', dl_path)
         finalpath = os.path.join(finaldir, dl_name)
         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():
             if not newfile:
-                newfile = os.path.join(finaldir, os.path.basename(encodeFilename(oldfile)))
-            oldfile, newfile = compat_str(oldfile), compat_str(newfile)
+                newfile = make_newfilename(oldfile)
             if os.path.abspath(encodeFilename(oldfile)) == os.path.abspath(encodeFilename(newfile)):
                 continue
             if not os.path.exists(encodeFilename(oldfile)):
@@ -50,5 +50,5 @@ def run(self, info):
             self.to_screen('Moving file "%s" to "%s"' % (oldfile, newfile))
             shutil.move(oldfile, newfile)  # os.rename cannot move between volumes
 
-        info['filepath'] = compat_str(finalpath)
+        info['filepath'] = finalpath
         return [], info
index 987f4bcc084536a51c7b08beaeb1b1a523e9dc8f..79a0f6a635cb9923d9b34951bc1cf36319a9536b 100644 (file)
@@ -4690,9 +4690,7 @@ def cli_configuration_args(params, arg_name, key, default=[], exe=None):  # retu
         return default, False
     assert isinstance(argdict, dict)
 
-    assert isinstance(key, compat_str)
     key = key.lower()
-
     args = exe_args = None
     if exe is not None:
         assert isinstance(exe, compat_str)