From a6e995c093de8aae2e91a0787281bb34c0b871eb Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Thu, 31 Jul 2025 01:22:01 -0400 Subject: New upstream version 1.30.2. --- gallery_dl/postprocessor/metadata.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'gallery_dl/postprocessor/metadata.py') diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py index fbb3fb8..c74f92f 100644 --- a/gallery_dl/postprocessor/metadata.py +++ b/gallery_dl/postprocessor/metadata.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2019-2023 Mike Fährmann +# Copyright 2019-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -55,8 +55,7 @@ class MetadataPP(PostProcessor): self._json_encode = self._make_encoder(options, 4).encode ext = "json" - base_directory = options.get("base-directory") - if base_directory: + if base_directory := options.get("base-directory"): if base_directory is True: self._base = lambda p: p.basedirectory else: @@ -139,9 +138,7 @@ class MetadataPP(PostProcessor): archive.add(pathfmt.kwdict) if self.mtime: - mtime = pathfmt.kwdict.get("_mtime") - if mtime: - util.set_mtime(path, mtime) + pathfmt.set_mtime(path) def _run_stdout(self, pathfmt): self.write(sys.stdout, pathfmt.kwdict) @@ -183,8 +180,7 @@ class MetadataPP(PostProcessor): try: pathfmt.directory_formatters = self._directory_formatters pathfmt.directory_conditions = () - segments = pathfmt.build_directory(pathfmt.kwdict) - if segments: + if segments := pathfmt.build_directory(pathfmt.kwdict): directory = pathfmt.clean_path(os.sep.join(segments) + os.sep) else: directory = "." + os.sep @@ -246,8 +242,7 @@ class MetadataPP(PostProcessor): fp.write(self._json_encode(kwdict) + "\n") def _make_filter(self, options): - include = options.get("include") - if include: + if include := options.get("include"): if isinstance(include, str): include = include.split(",") return lambda d: {k: d[k] for k in include if k in d} @@ -268,8 +263,7 @@ class MetadataPP(PostProcessor): if not private: return util.filter_dict - @staticmethod - def _make_encoder(options, indent=None): + def _make_encoder(self, options, indent=None): return json.JSONEncoder( ensure_ascii=options.get("ascii", False), sort_keys=options.get("sort", False), -- cgit v1.2.3