From a86ffb04bb898dfe113f3965cc5e8f42486b548b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 12 Apr 2021 01:55:55 +0200 Subject: [PATCH] add 'output.fallback' option to enable/disable fallback URLs for -g/--get-urls --- docs/configuration.rst | 10 ++++++++++ gallery_dl/__init__.py | 7 +++++-- gallery_dl/job.py | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index d89bba86..60fb5ae6 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1993,6 +1993,16 @@ Output Options ============== +output.fallback +--------------- +Type + ``bool`` +Default + ``true`` +Description + Include fallback URLs in the output of ``-g/--get-urls``. + + output.mode ----------- Type diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index c1f80b6e..5bf229a3 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014-2020 Mike Fährmann +# Copyright 2014-2021 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 @@ -9,7 +9,7 @@ from __future__ import unicode_literals, print_function __author__ = "Mike Fährmann" -__copyright__ = "Copyright 2014-2020 Mike Fährmann" +__copyright__ = "Copyright 2014-2021 Mike Fährmann" __license__ = "GPLv2" __maintainer__ = "Mike Fährmann" __email__ = "mike_faehrmann@web.de" @@ -204,6 +204,9 @@ def main(): if args.list_urls: jobtype = job.UrlJob jobtype.maxdepth = args.list_urls + if config.get(("output",), "fallback", True): + jobtype.handle_url = \ + staticmethod(jobtype.handle_url_fallback) else: jobtype = args.jobtype or job.DownloadJob diff --git a/gallery_dl/job.py b/gallery_dl/job.py index fcc90c4b..ad809e9b 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -575,7 +575,11 @@ class UrlJob(Job): self.handle_queue = self.handle_url @staticmethod - def handle_url(url, kwdict): + def handle_url(url, _): + print(url) + + @staticmethod + def handle_url_fallback(url, kwdict): print(url) if "_fallback" in kwdict: for url in kwdict["_fallback"]: