diff options
| author | 2022-11-22 04:28:38 -0500 | |
|---|---|---|
| committer | 2022-11-22 04:28:38 -0500 | |
| commit | 7af5cc29d1c02d20a6890b7b7ba78ab41532a763 (patch) | |
| tree | 4f0366e5653074c7eb31ac7ca59a1ee55f2d736e /gallery_dl/postprocessor | |
| parent | e59d46ecda74190381b1d2725b0bd9df5c0be8d8 (diff) | |
New upstream version 1.24.0.upstream/1.24.0
Diffstat (limited to 'gallery_dl/postprocessor')
| -rw-r--r-- | gallery_dl/postprocessor/compare.py | 5 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/metadata.py | 22 | ||||
| -rw-r--r-- | gallery_dl/postprocessor/ugoira.py | 13 |
3 files changed, 30 insertions, 10 deletions
diff --git a/gallery_dl/postprocessor/compare.py b/gallery_dl/postprocessor/compare.py index b3b94f7..910e1d7 100644 --- a/gallery_dl/postprocessor/compare.py +++ b/gallery_dl/postprocessor/compare.py @@ -51,8 +51,9 @@ class ComparePP(PostProcessor): num = 1 try: while not self._compare(pathfmt.realpath, pathfmt.temppath): - pathfmt.prefix = str(num) + "." - pathfmt.set_extension(pathfmt.extension, False) + pathfmt.prefix = prefix = format(num) + "." + pathfmt.kwdict["extension"] = prefix + pathfmt.extension + pathfmt.build_path() num += 1 return self._equal(pathfmt) except OSError: diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py index b21e483..2ee1cf8 100644 --- a/gallery_dl/postprocessor/metadata.py +++ b/gallery_dl/postprocessor/metadata.py @@ -21,6 +21,9 @@ class MetadataPP(PostProcessor): mode = options.get("mode") cfmt = options.get("content-format") or options.get("format") + omode = "w" + filename = None + if mode == "tags": self.write = self._write_tags ext = "txt" @@ -41,6 +44,12 @@ class MetadataPP(PostProcessor): cfmt = "\n".join(cfmt) + "\n" self._content_fmt = formatter.parse(cfmt).format_map ext = "txt" + elif mode == "jsonl": + self.write = self._write_json + self.indent = None + self.ascii = options.get("ascii", False) + omode = "a" + filename = "data.jsonl" else: self.write = self._write_json self.indent = options.get("indent", 4) @@ -53,7 +62,7 @@ class MetadataPP(PostProcessor): sep = os.sep + (os.altsep or "") self._metadir = util.expand_path(directory).rstrip(sep) + os.sep - filename = options.get("filename") + filename = options.get("filename", filename) extfmt = options.get("extension-format") if filename: if filename == "-": @@ -97,6 +106,9 @@ class MetadataPP(PostProcessor): self.archive = None self.mtime = options.get("mtime") + self.omode = options.get("open", omode) + self.encoding = options.get("encoding", "utf-8") + self.private = options.get("private", False) def run(self, pathfmt): archive = self.archive @@ -107,11 +119,11 @@ class MetadataPP(PostProcessor): path = directory + self._filename(pathfmt) try: - with open(path, "w", encoding="utf-8") as fp: + with open(path, self.omode, encoding=self.encoding) as fp: self.write(fp, pathfmt.kwdict) except FileNotFoundError: os.makedirs(directory, exist_ok=True) - with open(path, "w", encoding="utf-8") as fp: + with open(path, self.omode, encoding=self.encoding) as fp: self.write(fp, pathfmt.kwdict) if archive: @@ -198,7 +210,9 @@ class MetadataPP(PostProcessor): fp.write("\n".join(tags) + "\n") def _write_json(self, fp, kwdict): - util.dump_json(util.filter_dict(kwdict), fp, self.ascii, self.indent) + if not self.private: + kwdict = util.filter_dict(kwdict) + util.dump_json(kwdict, fp, self.ascii, self.indent) __postprocessor__ = MetadataPP diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index 98c8246..9d2cb34 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -90,15 +90,17 @@ class UgoiraPP(PostProcessor): if pathfmt.extension != "zip": return - if "frames" in pathfmt.kwdict: - self._frames = pathfmt.kwdict["frames"] - elif "pixiv_ugoira_frame_data" in pathfmt.kwdict: - self._frames = pathfmt.kwdict["pixiv_ugoira_frame_data"]["data"] + kwdict = pathfmt.kwdict + if "frames" in kwdict: + self._frames = kwdict["frames"] + elif "pixiv_ugoira_frame_data" in kwdict: + self._frames = kwdict["pixiv_ugoira_frame_data"]["data"] else: return if self.delete: pathfmt.set_extension(self.extension) + pathfmt.build_path() def convert(self, pathfmt): if not self._frames: @@ -115,6 +117,8 @@ class UgoiraPP(PostProcessor): # process frames and collect command-line arguments pathfmt.set_extension(self.extension) + pathfmt.build_path() + args = self._process(pathfmt, tempdir) if self.args: args += self.args @@ -151,6 +155,7 @@ class UgoiraPP(PostProcessor): pathfmt.delete = True else: pathfmt.set_extension("zip") + pathfmt.build_path() def _exec(self, args): self.log.debug(args) |
