This commit is contained in:
2026-02-11 18:16:07 -08:00
parent cc715e1fef
commit 1d0de1118b
27 changed files with 1167 additions and 1075 deletions

View File

@@ -287,48 +287,29 @@ class search_file(Cmdlet):
results = provider.search(query, limit=limit, filters=search_filters or None)
debug(f"[search-file] {provider_name} -> {len(results or [])} result(s)")
# Tidal artist UX: if there is exactly one artist match, auto-expand
# directly to albums without requiring an explicit @1 selection.
if (
provider_lower == "tidal"
and table_meta.get("view") == "artist"
and isinstance(results, list)
and len(results) == 1
):
try:
artist_res = results[0]
artist_name = str(getattr(artist_res, "title", "") or "").strip()
artist_md = getattr(artist_res, "full_metadata", None)
artist_id = 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
album_results = []
if hasattr(provider, "_albums_for_artist") and callable(getattr(provider, "_albums_for_artist")):
try:
album_results = provider._albums_for_artist( # type: ignore[attr-defined]
artist_id=artist_id,
artist_name=artist_name,
limit=max(int(limit or 0), 200),
)
except Exception:
album_results = []
if album_results:
results = album_results
table_type = "tidal.album"
# Allow providers to apply provider-specific UX transforms (e.g. auto-expansion)
try:
post = getattr(provider, "postprocess_search_results", None)
if callable(post) and isinstance(results, list):
results, table_type_override, table_meta_override = post(
query=query,
results=results,
filters=search_filters or None,
limit=int(limit or 0),
table_type=str(table_type or ""),
table_meta=dict(table_meta) if isinstance(table_meta, dict) else None,
)
if table_type_override:
table_type = str(table_type_override)
table.set_table(table_type)
table_meta["view"] = "album"
if isinstance(table_meta_override, dict) and table_meta_override:
table_meta = dict(table_meta_override)
try:
table.set_table_metadata(table_meta)
except Exception:
pass
except Exception:
pass
except Exception:
pass
if not results:
log(f"No results found for query: {query}", file=sys.stderr)