aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor/metadata.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:07 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:07 -0400
commitd9539f96cc7ac112b7d8faad022190fbbc88c745 (patch)
tree471249d60b9202c00d7d82abec8b296fc881292e /gallery_dl/postprocessor/metadata.py
parent889fc15f272118bf277737b6fac29d3faeffc641 (diff)
parenta6e995c093de8aae2e91a0787281bb34c0b871eb (diff)
Update upstream source from tag 'upstream/1.30.2'
Update to upstream version '1.30.2' with Debian dir f0dcd28a671f8600479182ff128e05ba8904a0d8
Diffstat (limited to 'gallery_dl/postprocessor/metadata.py')
-rw-r--r--gallery_dl/postprocessor/metadata.py18
1 files changed, 6 insertions, 12 deletions
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),