From 65ca923b4e5fe1fc401855a3e76e949eec70c622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 15 Feb 2021 21:58:33 +0100 Subject: [PATCH] fix 'whitelist' option for BaseExtractor instances --- gallery_dl/extractor/reactor.py | 3 ++- gallery_dl/job.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/reactor.py b/gallery_dl/extractor/reactor.py index aa0ba6de..4da095b1 100644 --- a/gallery_dl/extractor/reactor.py +++ b/gallery_dl/extractor/reactor.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2019-2020 Mike Fährmann +# Copyright 2019-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 @@ -24,6 +24,7 @@ class ReactorExtractor(Extractor): basecategory = "reactor" filename_fmt = "{post_id}_{num:>02}{title[:100]:?_//}.{extension}" archive_fmt = "{post_id}_{num}" + instances = () def __init__(self, match): Extractor.__init__(self, match) diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 2f68c594..6f6d64bc 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -10,6 +10,7 @@ import sys import time import errno import logging +import operator import collections from . import extractor, downloader, postprocessor from . import config, text, util, output, exception @@ -440,7 +441,21 @@ class DownloadJob(Job): if wlist is not None: if isinstance(wlist, str): wlist = wlist.split(",") - blist = {e.category for e in extractor._list_classes()} + + # build a set of all categories + blist = set() + add = blist.add + update = blist.update + get = operator.itemgetter(0) + + for extr in extractor._list_classes(): + category = extr.category + if category: + add(category) + else: + update(map(get, extr.instances)) + + # remove whitelisted categories blist.difference_update(wlist) return blist