Update PVideoDl to support custom download strategies and enhance cookie handling. Added new downloader registration system, updated README for clarity on downloaders, and introduced cookies configuration in settings. Frontend now includes a dedicated tab for download strategies and API endpoints for listing them.

This commit is contained in:
Leonid Pershin
2026-06-20 09:08:31 +03:00
parent 3e47e95fc4
commit eae4def0bf
15 changed files with 639 additions and 74 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Расширения-экстракторы для сайтов с непрямыми ссылками.
Каждый модуль здесь регистрирует свою стратегию декоратором @register из
app.services.downloader. Добавить сайт = положить сюда один файл; ядро не
трогаем. load_extractors() импортирует все модули пакета — её зовут на старте
приложения (lifespan в app/main.py).
"""
from __future__ import annotations
import importlib
import logging
import pkgutil
logger = logging.getLogger("pvideodl.extractors")
def load_extractors() -> list[str]:
"""Импортировать все модули пакета — при импорте они себя регистрируют.
Идемпотентно: при повторном вызове модули уже в sys.modules, их тело (а с ним
и @register) заново не выполняется — реестр не задваивается.
"""
loaded: list[str] = []
for info in pkgutil.iter_modules(__path__, __name__ + "."):
if info.name.rsplit(".", 1)[-1].startswith("_"):
continue
importlib.import_module(info.name)
loaded.append(info.name)
if loaded:
logger.info("Загружено экстракторов: %d (%s)", len(loaded), ", ".join(loaded))
return loaded