fix 'whitelist' option for BaseExtractor instances
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user