mirror of
https://github.com/RicterZ/nhentai.git
synced 2026-04-08 18:50:21 +02:00
Initial commit: doujinshi-dl generic plugin framework
History reset as part of DMCA compliance. The project has been refactored into a generic, site-agnostic download framework. Site-specific logic lives in separate plugin packages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
doujinshi_dl/core/registry.py
Normal file
28
doujinshi_dl/core/registry.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# coding: utf-8
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from doujinshi_dl.core.plugin import BasePlugin
|
||||
|
||||
|
||||
def get_plugin(name: str) -> 'BasePlugin':
|
||||
from importlib.metadata import entry_points
|
||||
eps = entry_points(group='doujinshi_dl.plugins')
|
||||
for ep in eps:
|
||||
if ep.name == name:
|
||||
return ep.load()
|
||||
raise KeyError(
|
||||
f"Plugin {name!r} not found. "
|
||||
f"Install it with: pip install doujinshi-dl-{name}"
|
||||
)
|
||||
|
||||
|
||||
def get_first_plugin() -> 'BasePlugin':
|
||||
from importlib.metadata import entry_points
|
||||
eps = list(entry_points(group='doujinshi_dl.plugins'))
|
||||
if not eps:
|
||||
raise RuntimeError(
|
||||
"No doujinshi-dl plugin installed. "
|
||||
"Install a plugin from PyPI, e.g.: pip install doujinshi-dl-<name>"
|
||||
)
|
||||
return eps[0].load()
|
||||
Reference in New Issue
Block a user