f
This commit is contained in:
@@ -17,7 +17,8 @@ from API.Tidal import (
|
||||
stringify,
|
||||
)
|
||||
from ProviderCore.base import Provider, SearchResult
|
||||
from cmdlet._shared import get_field
|
||||
from SYS.field_access import get_field
|
||||
from Provider.tidal_manifest import resolve_tidal_manifest_path
|
||||
from SYS import pipeline as pipeline_context
|
||||
from SYS.logger import debug, log
|
||||
|
||||
@@ -144,6 +145,62 @@ class Tidal(Provider):
|
||||
meta["view"] = self._get_view(query, filters)
|
||||
return meta
|
||||
|
||||
def postprocess_search_results(
|
||||
self,
|
||||
*,
|
||||
query: str,
|
||||
results: List[SearchResult],
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
limit: int = 50,
|
||||
table_type: str = "",
|
||||
table_meta: Optional[Dict[str, Any]] = None,
|
||||
) -> Tuple[List[SearchResult], Optional[str], Optional[Dict[str, Any]]]:
|
||||
_ = query
|
||||
_ = filters
|
||||
_ = table_type
|
||||
|
||||
# Provider-specific UX: if an artist search yields exactly one artist row,
|
||||
# auto-expand directly to albums (preserves historical cmdlet behavior).
|
||||
try:
|
||||
view = (table_meta or {}).get("view") if isinstance(table_meta, dict) else None
|
||||
if str(view or "").strip().lower() != "artist":
|
||||
return results, None, None
|
||||
except Exception:
|
||||
return results, None, None
|
||||
|
||||
if not isinstance(results, list) or len(results) != 1:
|
||||
return results, None, None
|
||||
|
||||
artist_res = results[0]
|
||||
artist_name = str(getattr(artist_res, "title", "") or "").strip()
|
||||
artist_md = getattr(artist_res, "full_metadata", None)
|
||||
|
||||
artist_id: Optional[int] = None
|
||||
if isinstance(artist_md, dict):
|
||||
raw_id = artist_md.get("artistId") or artist_md.get("id")
|
||||
try:
|
||||
artist_id = int(raw_id) if raw_id is not None else None
|
||||
except Exception:
|
||||
artist_id = None
|
||||
|
||||
# Use a floor of 200 to keep the expanded album list useful.
|
||||
want = max(int(limit or 0), 200)
|
||||
try:
|
||||
album_results = self._albums_for_artist(
|
||||
artist_id=artist_id,
|
||||
artist_name=artist_name,
|
||||
limit=want,
|
||||
)
|
||||
except Exception:
|
||||
album_results = []
|
||||
|
||||
if not album_results:
|
||||
return results, None, None
|
||||
|
||||
meta_out: Dict[str, Any] = dict(table_meta or {}) if isinstance(table_meta, dict) else {}
|
||||
meta_out["view"] = "album"
|
||||
return album_results, "tidal.album", meta_out
|
||||
|
||||
def __init__(self, config: Optional[Dict[str, Any]] = None) -> None:
|
||||
super().__init__(config)
|
||||
self.api_urls = self._resolve_api_urls()
|
||||
@@ -1304,11 +1361,6 @@ class Tidal(Provider):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
from cmdlet._shared import resolve_tidal_manifest_path
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
resolved = resolve_tidal_manifest_path({"full_metadata": md, "path": raw_path, "title": getattr(result, "title", "")})
|
||||
if not resolved:
|
||||
return None
|
||||
@@ -1349,9 +1401,11 @@ class Tidal(Provider):
|
||||
|
||||
# As a fallback, try downloading the URL directly if it looks like a file.
|
||||
try:
|
||||
import httpx
|
||||
from API.httpx_shared import get_shared_httpx_client
|
||||
|
||||
resp = httpx.get(resolved_text, timeout=float(getattr(self, "api_timeout", 10.0)))
|
||||
timeout_val = float(getattr(self, "api_timeout", 10.0))
|
||||
client = get_shared_httpx_client(timeout=timeout_val)
|
||||
resp = client.get(resolved_text, timeout=timeout_val)
|
||||
resp.raise_for_status()
|
||||
content = resp.content
|
||||
direct_path = output_dir / f"{stem}.bin"
|
||||
|
||||
Reference in New Issue
Block a user