From 319116c92306e5cc684d9d72776b0dd95644b324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 12 Sep 2024 20:52:51 +0200 Subject: [PATCH] [pp:ugoira] update mtime of zipped files (#6147) in zip archives generated by '"mode": "archive"' --- gallery_dl/postprocessor/ugoira.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index 557ac838..10d5f36a 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -253,18 +253,30 @@ class UgoiraPP(PostProcessor): self.delete = False if self.metadata: with zipfile.ZipFile(pathfmt.temppath, "a") as zfile: - with zfile.open(metaname, "w") as fp: + zinfo = zipfile.ZipInfo(metaname) + if self.mtime: + zinfo.date_time = zfile.infolist()[0].date_time + with zfile.open(zinfo, "w") as fp: fp.write(framedata) else: + if self.mtime: + dt = pathfmt.kwdict["date_url"] or pathfmt.kwdict["date"] + mtime = (dt.year, dt.month, dt.day, + dt.hour, dt.minute, dt.second) with zipfile.ZipFile(pathfmt.realpath, "w") as zfile: for frame in frames: zinfo = zipfile.ZipInfo.from_file( frame["path"], frame["file"]) + if self.mtime: + zinfo.date_time = mtime with open(frame["path"], "rb") as src, \ zfile.open(zinfo, "w") as dst: shutil.copyfileobj(src, dst, 1024*8) if self.metadata: - with zfile.open(metaname, "w") as fp: + zinfo = zipfile.ZipInfo(metaname) + if self.mtime: + zinfo.date_time = mtime + with zfile.open(zinfo, "w") as fp: fp.write(framedata) return True