update and cleanup repo
This commit is contained in:
@@ -10,11 +10,11 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from urllib.parse import quote, unquote, urlparse
|
||||
|
||||
from API.HTTP import _download_direct_file
|
||||
from API.HTTP import download_direct_file
|
||||
from PluginCore.base import Provider, SearchResult
|
||||
from SYS.utils import sanitize_filename, unique_path
|
||||
from SYS.logger import log
|
||||
from SYS.config import get_provider_block
|
||||
from SYS.config import get_plugin_block
|
||||
|
||||
# Helper for download-file: render selectable formats for a details URL.
|
||||
def maybe_show_formats_table(
|
||||
@@ -177,26 +177,20 @@ def _ia() -> Any:
|
||||
def _pick_provider_config(config: Any) -> Dict[str, Any]:
|
||||
if not isinstance(config, dict):
|
||||
return {}
|
||||
provider = config.get("provider")
|
||||
if not isinstance(provider, dict):
|
||||
return {}
|
||||
entry = provider.get("internetarchive")
|
||||
if isinstance(entry, dict):
|
||||
return entry
|
||||
return {}
|
||||
return get_plugin_block(config, "internetarchive")
|
||||
|
||||
|
||||
def _pick_archive_credentials(config: Any) -> tuple[Optional[str], Optional[str]]:
|
||||
"""Resolve Archive.org credentials.
|
||||
|
||||
Preference order:
|
||||
1) provider.internetarchive (email/username + password)
|
||||
2) provider.openlibrary (email + password)
|
||||
1) plugin.internetarchive (email/username + password)
|
||||
2) plugin.openlibrary (email + password)
|
||||
"""
|
||||
if not isinstance(config, dict):
|
||||
return None, None
|
||||
|
||||
ia_block = get_provider_block(config, "internetarchive")
|
||||
ia_block = get_plugin_block(config, "internetarchive")
|
||||
if isinstance(ia_block, dict):
|
||||
email = (
|
||||
ia_block.get("email")
|
||||
@@ -209,7 +203,7 @@ def _pick_archive_credentials(config: Any) -> tuple[Optional[str], Optional[str]
|
||||
if email_text and password_text:
|
||||
return email_text, password_text
|
||||
|
||||
ol_block = get_provider_block(config, "openlibrary")
|
||||
ol_block = get_plugin_block(config, "openlibrary")
|
||||
if isinstance(ol_block, dict):
|
||||
email = ol_block.get("email")
|
||||
password = ol_block.get("password")
|
||||
@@ -744,7 +738,7 @@ class InternetArchive(Provider):
|
||||
if tags:
|
||||
normalized["tags"] = tags
|
||||
normalized["media_kind"] = "book"
|
||||
normalized["provider_action"] = "borrow"
|
||||
normalized["plugin_action"] = "borrow"
|
||||
return normalized
|
||||
|
||||
def validate(self) -> bool:
|
||||
@@ -993,7 +987,7 @@ class InternetArchive(Provider):
|
||||
pipeline_progress = None
|
||||
|
||||
try:
|
||||
direct_result = _download_direct_file(
|
||||
direct_result = download_direct_file(
|
||||
raw_path,
|
||||
output_dir,
|
||||
quiet=quiet_mode,
|
||||
|
||||
Reference in New Issue
Block a user