From 550f90ab563f0b468e1cc01e4c04fbb39ec7dc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 9 Nov 2022 13:21:33 +0100 Subject: [PATCH] delay enabling .part files when 'http-metadata' is set otherwise 'build_path' gets called before all metadata is collected --- gallery_dl/downloader/http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index fb824361..e7a51be2 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -91,11 +91,12 @@ class HttpDownloader(DownloaderBase): tries = 0 msg = "" + metadata = self.metadata kwdict = pathfmt.kwdict adjust_extension = kwdict.get( "_http_adjust_extension", self.adjust_extension) - if self.part: + if self.part and not metadata: pathfmt.part_enable(self.partdir) while True: @@ -194,15 +195,19 @@ class HttpDownloader(DownloaderBase): build_path = True # set metadata from HTTP headers - if self.metadata: - kwdict[self.metadata] = util.extract_headers(response) + if metadata: + kwdict[metadata] = util.extract_headers(response) build_path = True + # build and check file path if build_path: pathfmt.build_path() if pathfmt.exists(): pathfmt.temppath = "" return True + if self.part and metadata: + pathfmt.part_enable(self.partdir) + metadata = False content = response.iter_content(self.chunk_size)