[wikimedia] implement config lookup for fandom/wikigg sites (#7283)

{
    "extractor": {
        "fandom": {
            "filename": "..."
        }
    }
}
This commit is contained in:
Mike Fährmann
2025-10-23 18:54:28 +02:00
parent eefd8f9c00
commit 98d3354575
5 changed files with 6 additions and 0 deletions

View File

@@ -961,6 +961,7 @@ class AsynchronousMixin():
class BaseExtractor(Extractor):
basesubcategory = ""
instances = ()
def __init__(self, match):

View File

@@ -180,6 +180,7 @@ class E621FavoriteExtractor(E621Extractor):
class E621FrontendExtractor(Extractor):
"""Extractor for alternative e621 frontends"""
basecategory = "E621"
basesubcategory = ""
category = "e621"
subcategory = "frontend"
pattern = r"(?:https?://)?e621\.(?:cc/\?tags|anthro\.fr/\?q)=([^&#]*)"

View File

@@ -27,6 +27,7 @@ class WikimediaExtractor(BaseExtractor):
if self.category == "wikimedia":
self.category = self.root.split(".")[-2]
elif self.category in ("fandom", "wikigg"):
self.basesubcategory = self.category
self.category = (
f"{self.category}-"
f"{self.root.partition('.')[0].rpartition('/')[2]}")

View File

@@ -130,6 +130,8 @@ class Job():
if extr.basecategory:
if not cfgpath:
cfgpath.append((extr.category, extr.subcategory))
if extr.basesubcategory:
cfgpath.append((extr.basesubcategory, extr.subcategory))
cfgpath.append((extr.basecategory, extr.subcategory))
return cfgpath

View File

@@ -214,6 +214,7 @@ Request interval (default):
def test_base_category(self):
extr = TestExtractor.from_url("test:")
extr.basecategory = "test_basecategory"
extr.basesubcategory = "test_basesubcategory"
self.assertEqual(self._capture_stdout(extr), """\
Category / Subcategory / Basecategory