kk
This commit is contained in:
@@ -568,6 +568,18 @@ class AllDebrid(TableProviderMixin, Provider):
|
||||
URL = ("magnet:",)
|
||||
URL_DOMAINS = ()
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "api_key",
|
||||
"label": "API Key",
|
||||
"default": "",
|
||||
"required": True,
|
||||
"secret": True
|
||||
}
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def _resolve_magnet_spec_from_result(result: Any) -> Optional[str]:
|
||||
table = getattr(result, "table", None)
|
||||
|
||||
@@ -50,6 +50,33 @@ def _extract_key(payload: Any) -> Optional[str]:
|
||||
|
||||
class FileIO(Provider):
|
||||
"""File provider for file.io."""
|
||||
PROVIDER_NAME = "file.io"
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "api_key",
|
||||
"label": "API Key",
|
||||
"default": "",
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "expires",
|
||||
"label": "Default Expiration (e.g. 1w)",
|
||||
"default": "1w"
|
||||
},
|
||||
{
|
||||
"key": "maxDownloads",
|
||||
"label": "Max Downloads",
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"key": "autoDelete",
|
||||
"label": "Auto Delete",
|
||||
"default": True
|
||||
}
|
||||
]
|
||||
|
||||
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
||||
super().__init__(config)
|
||||
|
||||
@@ -464,16 +464,36 @@ class InternetArchive(Provider):
|
||||
- search-file -provider internetarchive <query>
|
||||
- download-file / provider.download() from search results
|
||||
- add-file -provider internetarchive (uploads)
|
||||
|
||||
Config (optional):
|
||||
[provider=internetarchive]
|
||||
access_key="..." # optional (upload)
|
||||
secret_key="..." # optional (upload)
|
||||
collection="..." # optional (upload)
|
||||
mediatype="..." # optional (upload)
|
||||
"""
|
||||
URL = ("archive.org",)
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "access_key",
|
||||
"label": "Access Key (for uploads)",
|
||||
"default": "",
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "secret_key",
|
||||
"label": "Secret Key (for uploads)",
|
||||
"default": "",
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "collection",
|
||||
"label": "Default Collection",
|
||||
"default": ""
|
||||
},
|
||||
{
|
||||
"key": "mediatype",
|
||||
"label": "Default Mediatype",
|
||||
"default": ""
|
||||
}
|
||||
]
|
||||
|
||||
TABLE_AUTO_STAGES = {
|
||||
"internetarchive": ["download-file"],
|
||||
"internetarchive.folder": ["download-file"],
|
||||
|
||||
@@ -234,6 +234,29 @@ class Matrix(TableProviderMixin, Provider):
|
||||
4. Selection triggers upload of pending files to selected rooms
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "homeserver",
|
||||
"label": "Homeserver URL",
|
||||
"default": "https://matrix.org",
|
||||
"required": True
|
||||
},
|
||||
{
|
||||
"key": "access_token",
|
||||
"label": "Access Token",
|
||||
"default": "",
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "password",
|
||||
"label": "Password (fallback)",
|
||||
"default": "",
|
||||
"secret": True
|
||||
}
|
||||
]
|
||||
|
||||
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
||||
super().__init__(config)
|
||||
self._init_ok: Optional[bool] = None
|
||||
|
||||
@@ -28,6 +28,13 @@ from Provider.metadata_provider import (
|
||||
from SYS.utils import unique_path
|
||||
|
||||
_ARCHIVE_VERIFY_VALUE = get_requests_verify_value()
|
||||
_DEFAULT_ARCHIVE_SCALE = 4
|
||||
_QUALITY_TO_ARCHIVE_SCALE = {
|
||||
"high": 2,
|
||||
"medium": 5,
|
||||
"low": 8,
|
||||
}
|
||||
|
||||
|
||||
def _create_archive_session() -> requests.Session:
|
||||
session = requests.Session()
|
||||
@@ -279,17 +286,30 @@ class OpenLibrary(Provider):
|
||||
"openlibrary": ["download-file"],
|
||||
}
|
||||
|
||||
REQUIRED_CONFIG_KEYS = (
|
||||
"email",
|
||||
"password",
|
||||
)
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "email",
|
||||
"label": "Archive.org Email",
|
||||
"default": "",
|
||||
"required": True
|
||||
},
|
||||
{
|
||||
"key": "password",
|
||||
"label": "Archive.org Password",
|
||||
"default": "",
|
||||
"required": True,
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "quality",
|
||||
"label": "Image Quality",
|
||||
"default": "medium",
|
||||
"placeholder": "high, medium, low"
|
||||
}
|
||||
]
|
||||
|
||||
DEFAULT_ARCHIVE_SCALE = 4
|
||||
QUALITY_TO_ARCHIVE_SCALE = {
|
||||
"high": 2,
|
||||
"medium": 5,
|
||||
"low": 8,
|
||||
}
|
||||
# Domains that should be routed to this provider when the user supplies a URL.
|
||||
# (Used by ProviderCore.registry.match_provider_name_for_url)
|
||||
URL_DOMAINS = (
|
||||
@@ -342,88 +362,53 @@ class OpenLibrary(Provider):
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _credential_archive(config: Dict[str,
|
||||
Any]) -> Tuple[Optional[str],
|
||||
Optional[str]]:
|
||||
"""Get Archive.org email/password from config.
|
||||
|
||||
Supports:
|
||||
- New: {"provider": {"openlibrary": {"email": "...", "password": "..."}}}
|
||||
- Old: {"Archive": {"email": "...", "password": "..."}}
|
||||
{"archive_org_email": "...", "archive_org_password": "..."}
|
||||
"""
|
||||
def _credential_archive(config: Dict[str, Any]) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""Get Archive.org email/password from config."""
|
||||
if not isinstance(config, dict):
|
||||
return None, None
|
||||
|
||||
provider_config = config.get("provider",
|
||||
{})
|
||||
if isinstance(provider_config, dict):
|
||||
openlibrary_config = provider_config.get("openlibrary",
|
||||
{})
|
||||
if isinstance(openlibrary_config, dict):
|
||||
email = openlibrary_config.get("email")
|
||||
password = openlibrary_config.get("password")
|
||||
if email or password:
|
||||
return str(email) if email is not None else None, (
|
||||
str(password) if password is not None else None
|
||||
)
|
||||
|
||||
archive_config = config.get("Archive")
|
||||
if isinstance(archive_config, dict):
|
||||
email = archive_config.get("email")
|
||||
password = archive_config.get("password")
|
||||
entry = config.get("provider", {}).get("openlibrary", {})
|
||||
if isinstance(entry, dict):
|
||||
email = entry.get("email")
|
||||
password = entry.get("password")
|
||||
if email or password:
|
||||
return str(email) if email is not None else None, (
|
||||
str(password) if password is not None else None
|
||||
)
|
||||
|
||||
email = config.get("archive_org_email")
|
||||
password = config.get("archive_org_password")
|
||||
return str(email) if email is not None else None, (
|
||||
str(password) if password is not None else None
|
||||
)
|
||||
return None, None
|
||||
|
||||
@classmethod
|
||||
def _archive_scale_from_config(cls, config: Dict[str, Any]) -> int:
|
||||
"""Resolve Archive.org book-reader scale from provider config.
|
||||
|
||||
Config:
|
||||
[provider=OpenLibrary]
|
||||
quality="medium" # High=2, Medium=5, Low=8
|
||||
|
||||
Default when missing/invalid: 4.
|
||||
"""
|
||||
|
||||
default_scale = int(getattr(cls, "DEFAULT_ARCHIVE_SCALE", 4) or 4)
|
||||
"""Resolve Archive.org book-reader scale from provider config."""
|
||||
if not isinstance(config, dict):
|
||||
return default_scale
|
||||
return _DEFAULT_ARCHIVE_SCALE
|
||||
|
||||
provider_config = config.get("provider", {})
|
||||
openlibrary_config = None
|
||||
if isinstance(provider_config, dict):
|
||||
openlibrary_config = provider_config.get("openlibrary")
|
||||
if not isinstance(openlibrary_config, dict):
|
||||
openlibrary_config = {}
|
||||
entry = config.get("provider", {}).get("openlibrary", {})
|
||||
if not isinstance(entry, dict):
|
||||
return _DEFAULT_ARCHIVE_SCALE
|
||||
|
||||
raw_quality = openlibrary_config.get("quality")
|
||||
raw_quality = entry.get("quality")
|
||||
if raw_quality is None:
|
||||
return default_scale
|
||||
return _DEFAULT_ARCHIVE_SCALE
|
||||
|
||||
if isinstance(raw_quality, (int, float)):
|
||||
try:
|
||||
val = int(raw_quality)
|
||||
except Exception:
|
||||
return default_scale
|
||||
return val if val > 0 else default_scale
|
||||
val = int(raw_quality)
|
||||
return val if val > 0 else _DEFAULT_ARCHIVE_SCALE
|
||||
|
||||
q = str(raw_quality).strip().lower()
|
||||
if not q:
|
||||
return _DEFAULT_ARCHIVE_SCALE
|
||||
|
||||
mapped = _QUALITY_TO_ARCHIVE_SCALE.get(q)
|
||||
if isinstance(mapped, int) and mapped > 0:
|
||||
return mapped
|
||||
|
||||
try:
|
||||
q = str(raw_quality).strip().lower()
|
||||
val = int(q)
|
||||
return val if val > 0 else _DEFAULT_ARCHIVE_SCALE
|
||||
except Exception:
|
||||
return default_scale
|
||||
if not q:
|
||||
return default_scale
|
||||
|
||||
mapped = cls.QUALITY_TO_ARCHIVE_SCALE.get(q)
|
||||
return _DEFAULT_ARCHIVE_SCALE
|
||||
if isinstance(mapped, int) and mapped > 0:
|
||||
return mapped
|
||||
|
||||
|
||||
@@ -210,6 +210,24 @@ class Soulseek(Provider):
|
||||
}
|
||||
"""Search provider for Soulseek P2P network."""
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "username",
|
||||
"label": "Soulseek Username",
|
||||
"default": "",
|
||||
"required": True
|
||||
},
|
||||
{
|
||||
"key": "password",
|
||||
"label": "Soulseek Password",
|
||||
"default": "",
|
||||
"required": True,
|
||||
"secret": True
|
||||
}
|
||||
]
|
||||
|
||||
MUSIC_EXTENSIONS = {
|
||||
".flac",
|
||||
".mp3",
|
||||
|
||||
@@ -149,6 +149,30 @@ class Telegram(Provider):
|
||||
"""
|
||||
URL = ("t.me", "telegram.me")
|
||||
|
||||
@classmethod
|
||||
def config(cls) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
"key": "app_id",
|
||||
"label": "API ID (from my.telegram.org)",
|
||||
"default": "",
|
||||
"required": True
|
||||
},
|
||||
{
|
||||
"key": "api_hash",
|
||||
"label": "API Hash",
|
||||
"default": "",
|
||||
"required": True,
|
||||
"secret": True
|
||||
},
|
||||
{
|
||||
"key": "bot_token",
|
||||
"label": "Bot Token (optional)",
|
||||
"default": "",
|
||||
"secret": True
|
||||
}
|
||||
]
|
||||
|
||||
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
||||
super().__init__(config)
|
||||
telegram_conf = (
|
||||
|
||||
Reference in New Issue
Block a user