This commit is contained in:
2026-01-03 21:23:55 -08:00
parent 73f3005393
commit 3acf21a673
10 changed files with 1244 additions and 43 deletions

View File

@@ -205,7 +205,7 @@ class Download_File(Cmdlet):
elif isinstance(collection, str):
values = [collection.strip().lower()] if collection.strip() else []
lendable = any(v in {"inlibrary", "printdisabled", "lendinglibrary"} for v in values)
lendable = any(v in {"inlibrary", "lendinglibrary"} for v in values)
except Exception:
lendable = False

View File

@@ -280,6 +280,49 @@ class search_file(Cmdlet):
results = provider.search(query, limit=limit)
debug(f"[search-file] {provider_name} -> {len(results or [])} result(s)")
# HIFI artist UX: if there is exactly one artist match, auto-expand
# directly to albums without requiring an explicit @1 selection.
if (
provider_lower == "hifi"
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 = "hifi.album"
table.set_table(table_type)
table_meta["view"] = "album"
try:
table.set_table_metadata(table_meta)
except Exception:
pass
except Exception:
pass
if not results:
log(f"No results found for query: {query}", file=sys.stderr)
if db is not None: