From 29d315e495a4965dad2ae3ff55488fa26588c645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 21 May 2025 12:29:37 +0200 Subject: [PATCH] [dl:ytdl] improve temp/part file handling (#6949 #7494) - fixes files not being moved from 'part-directory' (#6949) - fixes 'skip: enumerate' overwriting files (#7494) --- gallery_dl/downloader/ytdl.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py index 7a20dc2c..1fc2f827 100644 --- a/gallery_dl/downloader/ytdl.py +++ b/gallery_dl/downloader/ytdl.py @@ -130,18 +130,27 @@ class YoutubeDLDownloader(DownloaderBase): if pathfmt.exists(): pathfmt.temppath = "" return True - if self.part and self.partdir: - pathfmt.temppath = os.path.join( - self.partdir, pathfmt.filename) - - self._set_outtmpl(ytdl_instance, pathfmt.temppath.replace("%", "%%")) self.out.start(pathfmt.path) + if self.part: + pathfmt.kwdict["extension"] = pathfmt.prefix + "part" + filename = pathfmt.build_filename(pathfmt.kwdict) + pathfmt.kwdict["extension"] = info_dict["ext"] + if self.partdir: + path = os.path.join(self.partdir, filename) + else: + path = pathfmt.realdirectory + filename + else: + path = pathfmt.realpath + + self._set_outtmpl(ytdl_instance, path.replace("%", "%%")) try: ytdl_instance.process_info(info_dict) except Exception as exc: self.log.debug("", exc_info=exc) return False + + pathfmt.temppath = info_dict["filepath"] return True def _download_playlist(self, ytdl_instance, pathfmt, info_dict):