re-implement 'category-map' (#7612)
This commit is contained in:
@@ -7494,6 +7494,33 @@ Description
|
||||
or by `extractor.modules`_.
|
||||
|
||||
|
||||
extractor.category-map
|
||||
----------------------
|
||||
Type
|
||||
* ``object`` (`category` -> `category`)
|
||||
* ``string``
|
||||
Example
|
||||
.. code:: json
|
||||
|
||||
{
|
||||
"danbooru": "booru",
|
||||
"gelbooru": "booru"
|
||||
}
|
||||
Description
|
||||
A JSON object mapping category names to their replacements.
|
||||
|
||||
Special values:
|
||||
|
||||
* ``"compat"``
|
||||
.. code:: json
|
||||
|
||||
{
|
||||
"coomer" : "coomerparty",
|
||||
"kemono" : "kemonoparty",
|
||||
"schalenetwork": "koharu"
|
||||
}
|
||||
|
||||
|
||||
extractor.config-map
|
||||
--------------------
|
||||
Type
|
||||
|
||||
@@ -79,11 +79,6 @@
|
||||
"actions": [],
|
||||
"input" : null,
|
||||
"netrc" : false,
|
||||
"config-map": {
|
||||
"coomerparty": "coomer",
|
||||
"kemonoparty": "kemono",
|
||||
"koharu" : "schalenetwork"
|
||||
},
|
||||
"extension-map": {
|
||||
"jpeg": "jpg",
|
||||
"jpe" : "jpg",
|
||||
@@ -92,6 +87,14 @@
|
||||
"jfi" : "jpg"
|
||||
},
|
||||
|
||||
"category-map": {},
|
||||
"config-map": {
|
||||
"coomerparty": "coomer",
|
||||
"kemonoparty": "kemono",
|
||||
"koharu" : "schalenetwork"
|
||||
},
|
||||
|
||||
|
||||
|
||||
"#": "===============================================================",
|
||||
"#": "==== Site-specific Extractor Options ====================",
|
||||
|
||||
@@ -317,6 +317,17 @@ def main():
|
||||
args.loglevel < logging.ERROR:
|
||||
input_manager.progress(pformat)
|
||||
|
||||
catmap = config.interpolate(("extractor",), "category-map")
|
||||
if catmap:
|
||||
if catmap == "compat":
|
||||
catmap = {
|
||||
"coomer" : "coomerparty",
|
||||
"kemono" : "kemonoparty",
|
||||
"schalenetwork": "koharu",
|
||||
}
|
||||
from .extractor import common
|
||||
common.CATEGORY_MAP = catmap
|
||||
|
||||
# process input URLs
|
||||
retval = 0
|
||||
for url in input_manager:
|
||||
|
||||
@@ -53,6 +53,9 @@ class Extractor():
|
||||
self.url = match.string
|
||||
self.match = match
|
||||
self.groups = match.groups()
|
||||
|
||||
if self.category in CATEGORY_MAP:
|
||||
self.category = CATEGORY_MAP[self.category]
|
||||
self._cfgpath = ("extractor", self.category, self.subcategory)
|
||||
self._parentdir = ""
|
||||
|
||||
@@ -964,7 +967,7 @@ def _browser_useragent():
|
||||
|
||||
_adapter_cache = {}
|
||||
_browser_cookies = {}
|
||||
|
||||
CATEGORY_MAP = ()
|
||||
|
||||
HTTP_HEADERS = {
|
||||
"firefox": (
|
||||
|
||||
Reference in New Issue
Block a user