add config option for unsupported-URL file

for consistency's sake
This commit is contained in:
Mike Fährmann
2018-01-28 18:42:10 +01:00
parent 619387cbb1
commit d951f13e37
4 changed files with 16 additions and 5 deletions

View File

@@ -99,6 +99,15 @@ Description File to write logging output to.
=========== ===== =========== =====
output.unsupportedfile
----------------------
=========== =====
Type ``string``
Default ``null``
Description File to write external URLs unsupported by *gallery-dl* to.
=========== =====
Downloader Options Downloader Options
================== ==================

View File

@@ -129,5 +129,6 @@
"shorten": true, "shorten": true,
"progress": true, "progress": true,
"logfile": null, "logfile": null,
"unsupportedfile": null
} }
} }

View File

@@ -104,7 +104,7 @@ def main():
path = util.expand_path(logfile) path = util.expand_path(logfile)
handler = logging.FileHandler(path, "w") handler = logging.FileHandler(path, "w")
except OSError as exc: except OSError as exc:
log.warning("logfile: %s", exc) log.warning("log file: %s", exc)
else: else:
handler.setFormatter(formatter) handler.setFormatter(formatter)
logging.getLogger().addHandler(handler) logging.getLogger().addHandler(handler)
@@ -165,11 +165,12 @@ def main():
urls += sanatize_input(file) urls += sanatize_input(file)
file.close() file.close()
except OSError as exc: except OSError as exc:
log.warning("input-file: %s", exc) log.warning("input file: %s", exc)
if args.unsupportedfile: unsupportedfile = config.interpolate(("output", "unsupportedfile"))
if unsupportedfile:
try: try:
path = util.expand_path(args.unsupportedfile) path = util.expand_path(unsupportedfile)
job.Job.ufile = open(path, "w") job.Job.ufile = open(path, "w")
except OSError as exc: except OSError as exc:
log.warning("unsupported-URL file: %s", exc) log.warning("unsupported-URL file: %s", exc)

View File

@@ -129,7 +129,7 @@ def build_parser():
) )
output.add_argument( output.add_argument(
"--write-unsupported", "--write-unsupported",
metavar="FILE", dest="unsupportedfile", metavar="FILE", dest="unsupportedfile", action=ConfigAction,
help=("Write URLs, which get emitted by other extractors but cannot " help=("Write URLs, which get emitted by other extractors but cannot "
"be handled, to FILE"), "be handled, to FILE"),
) )