aboutsummaryrefslogtreecommitdiffstats
path: root/scrapers
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-03-12 13:56:30 -0700
committerPinapelz <yukais@pinapelz.com>2026-03-12 13:56:50 -0700
commitcaa3cf245186ab0f6fb33e63a7dd838d834da12e (patch)
treebc5742a134ecabf0b9d35cc12b1d6f67defd5da7 /scrapers
parent5658441ab9b703c95a48e654d41e45cc3a55ffd3 (diff)
refactor: move to common NewsSource interface
cleanup imports by defining initaliazers modules and decorator remove legacy scrapers remove single factory for sega games (sites don't change that much)
Diffstat (limited to 'scrapers')
-rw-r--r--scrapers/__init__.py0
-rw-r--r--scrapers/base.py8
-rw-r--r--scrapers/registry.py22
3 files changed, 30 insertions, 0 deletions
diff --git a/scrapers/__init__.py b/scrapers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scrapers/__init__.py
diff --git a/scrapers/base.py b/scrapers/base.py
new file mode 100644
index 0000000..8d9839f
--- /dev/null
+++ b/scrapers/base.py
@@ -0,0 +1,8 @@
+from abc import ABC, abstractmethod
+
+
+class NewsSource(ABC):
+
+ @abstractmethod
+ def fetch(self, version=None) -> list[dict]:
+ pass
diff --git a/scrapers/registry.py b/scrapers/registry.py
new file mode 100644
index 0000000..6d9bde6
--- /dev/null
+++ b/scrapers/registry.py
@@ -0,0 +1,22 @@
+from __future__ import annotations
+from typing import Optional, TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from scrapers.base import NewsSource
+
+_registry: dict[str, type["NewsSource"]] = {}
+
+
+def register(url_key: str):
+ def decorator(cls):
+ _registry[url_key] = cls
+ return cls
+ return decorator
+
+
+def get_source(url_key: str) -> Optional[type["NewsSource"]]:
+ return _registry.get(url_key)
+
+
+def get_all() -> dict[str, type["NewsSource"]]:
+ return dict(_registry)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage