aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-12-20 05:49:04 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2025-12-20 05:49:04 -0500
commita24ec1647aeac35a63b744ea856011ad6e06be3b (patch)
treeae94416de786aeddd05d99559098f7f16bb103a6 /gallery_dl/postprocessor
parent33f8a8a37a9cba738ef25fb99955f0730da9eb48 (diff)
New upstream version 1.31.1.upstream/1.31.1
Diffstat (limited to 'gallery_dl/postprocessor')
-rw-r--r--gallery_dl/postprocessor/__init__.py2
-rw-r--r--gallery_dl/postprocessor/exec.py9
-rw-r--r--gallery_dl/postprocessor/metadata.py10
-rw-r--r--gallery_dl/postprocessor/mtime.py7
-rw-r--r--gallery_dl/postprocessor/ugoira.py6
5 files changed, 22 insertions, 12 deletions
diff --git a/gallery_dl/postprocessor/__init__.py b/gallery_dl/postprocessor/__init__.py
index 1a4ce56..6da0330 100644
--- a/gallery_dl/postprocessor/__init__.py
+++ b/gallery_dl/postprocessor/__init__.py
@@ -33,7 +33,7 @@ def find(name):
cls = None
if name in modules: # prevent unwanted imports
try:
- module = __import__(name, globals(), None, (), 1)
+ module = __import__(name, globals(), None, None, 1)
except ImportError:
pass
else:
diff --git a/gallery_dl/postprocessor/exec.py b/gallery_dl/postprocessor/exec.py
index 3b0ab22..9e2e4df 100644
--- a/gallery_dl/postprocessor/exec.py
+++ b/gallery_dl/postprocessor/exec.py
@@ -22,6 +22,10 @@ else:
from shlex import quote
+def trim(args):
+ return (args.partition(" ") if isinstance(args, str) else args)[0]
+
+
class ExecPP(PostProcessor):
def __init__(self, job, options):
@@ -35,6 +39,7 @@ class ExecPP(PostProcessor):
if options.get("async", False):
self._exec = self._popen
+ self.verbose = options.get("verbose", True)
self.session = False
self.creationflags = 0
if options.get("session"):
@@ -115,11 +120,11 @@ class ExecPP(PostProcessor):
def _exec(self, args, shell):
if retcode := self._popen(args, shell).wait():
self.log.warning("'%s' returned with non-zero exit status (%d)",
- args, retcode)
+ args if self.verbose else trim(args), retcode)
return retcode
def _popen(self, args, shell):
- self.log.debug("Running '%s'", args)
+ self.log.debug("Running '%s'", args if self.verbose else trim(args))
return util.Popen(
args,
shell=shell,
diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py
index 90e6e3d..0017b5b 100644
--- a/gallery_dl/postprocessor/metadata.py
+++ b/gallery_dl/postprocessor/metadata.py
@@ -117,9 +117,15 @@ class MetadataPP(PostProcessor):
self.mtime = options.get("mtime")
self.omode = options.get("open", omode)
self.encoding = options.get("encoding", "utf-8")
+ self.newline = options.get("newline")
self.skip = options.get("skip", False)
self.meta_path = options.get("metadata-path")
+ def open(self, path):
+ return open(path, self.omode,
+ encoding=self.encoding,
+ newline=self.newline)
+
def run(self, pathfmt):
archive = self.archive
if archive and archive.check(pathfmt.kwdict):
@@ -138,11 +144,11 @@ class MetadataPP(PostProcessor):
return
try:
- with open(path, self.omode, encoding=self.encoding) as fp:
+ with self.open(path) as fp:
self.write(fp, pathfmt.kwdict)
except FileNotFoundError:
os.makedirs(directory, exist_ok=True)
- with open(path, self.omode, encoding=self.encoding) as fp:
+ with self.open(path) as fp:
self.write(fp, pathfmt.kwdict)
if archive:
diff --git a/gallery_dl/postprocessor/mtime.py b/gallery_dl/postprocessor/mtime.py
index b1269dd..7d4796e 100644
--- a/gallery_dl/postprocessor/mtime.py
+++ b/gallery_dl/postprocessor/mtime.py
@@ -9,8 +9,7 @@
"""Use metadata as file modification time"""
from .common import PostProcessor
-from .. import text, util, formatter
-from datetime import datetime
+from .. import text, util, dt, formatter
class MtimePP(PostProcessor):
@@ -36,8 +35,8 @@ class MtimePP(PostProcessor):
return
pathfmt.kwdict["_mtime_meta"] = (
- util.datetime_to_timestamp(mtime)
- if isinstance(mtime, datetime) else
+ dt.to_ts(mtime)
+ if isinstance(mtime, dt.datetime) else
text.parse_int(mtime)
)
diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py
index 1a55e22..3813fae 100644
--- a/gallery_dl/postprocessor/ugoira.py
+++ b/gallery_dl/postprocessor/ugoira.py
@@ -151,7 +151,7 @@ class UgoiraPP(PostProcessor):
"%s: Unable to extract frames from %s (%s: %s)",
pathfmt.kwdict.get("id"), pathfmt.filename,
exc.__class__.__name__, exc)
- return self.log.debug("", exc_info=exc)
+ return self.log.traceback(exc)
if self.convert(pathfmt, tempdir):
if self.delete:
@@ -227,12 +227,12 @@ class UgoiraPP(PostProcessor):
output.stderr_write("\n")
self.log.error("Unable to invoke FFmpeg (%s: %s)",
exc.__class__.__name__, exc)
- self.log.debug("", exc_info=exc)
+ self.log.traceback(exc)
pathfmt.realpath = pathfmt.temppath
except Exception as exc:
output.stderr_write("\n")
self.log.error("%s: %s", exc.__class__.__name__, exc)
- self.log.debug("", exc_info=exc)
+ self.log.traceback(exc)
pathfmt.realpath = pathfmt.temppath
else:
if self.mtime: