diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-04-11 03:48:07 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-04-12 02:12:46 +0530 |
commit | 56d868dbb7c72e4fbe9d28d4837cc59261d8fe55 (patch) | |
tree | 33681efe7458f2d33daaac6306ba42dffad2e3b7 /yt_dlp/postprocessor/movefilesafterdownload.py | |
parent | f4f751af409a1db86215b87cc424960a8236ee93 (diff) | |
download | hypervideo-pre-56d868dbb7c72e4fbe9d28d4837cc59261d8fe55.tar.lz hypervideo-pre-56d868dbb7c72e4fbe9d28d4837cc59261d8fe55.tar.xz hypervideo-pre-56d868dbb7c72e4fbe9d28d4837cc59261d8fe55.zip |
Allow running some `postprocessors` before actual download
Diffstat (limited to 'yt_dlp/postprocessor/movefilesafterdownload.py')
-rw-r--r-- | yt_dlp/postprocessor/movefilesafterdownload.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/yt_dlp/postprocessor/movefilesafterdownload.py b/yt_dlp/postprocessor/movefilesafterdownload.py index 0ab7744ca..1064a8cb8 100644 --- a/yt_dlp/postprocessor/movefilesafterdownload.py +++ b/yt_dlp/postprocessor/movefilesafterdownload.py @@ -13,6 +13,10 @@ from ..utils import ( class MoveFilesAfterDownloadPP(PostProcessor): + def __init__(self, downloader=None, downloaded=True): + PostProcessor.__init__(self, downloader) + self._downloaded = downloaded + @classmethod def pp_key(cls): return 'MoveFiles' @@ -21,7 +25,8 @@ class MoveFilesAfterDownloadPP(PostProcessor): dl_path, dl_name = os.path.split(encodeFilename(info['filepath'])) finaldir = info.get('__finaldir', dl_path) finalpath = os.path.join(finaldir, dl_name) - info['__files_to_move'][info['filepath']] = decodeFilename(finalpath) + if self._downloaded: + info['__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 info['__files_to_move'].items(): |