j
This commit is contained in:
13
API/hifi.py
13
API/hifi.py
@@ -18,6 +18,7 @@ class HifiApiClient:
|
||||
- GET /search/ with exactly one of s, a, v, p
|
||||
- GET /track/ with id (and optional quality)
|
||||
- GET /info/ with id
|
||||
- GET /lyrics/ with id
|
||||
"""
|
||||
|
||||
def __init__(self, base_url: str = DEFAULT_BASE_URL, *, timeout: float = 10.0) -> None:
|
||||
@@ -66,3 +67,15 @@ class HifiApiClient:
|
||||
raise HifiApiError("track_id must be positive")
|
||||
|
||||
return self._get_json("info/", params={"id": track_int})
|
||||
|
||||
def lyrics(self, track_id: int) -> Dict[str, Any]:
|
||||
"""Fetch lyrics (including subtitles/LRC) for a track."""
|
||||
|
||||
try:
|
||||
track_int = int(track_id)
|
||||
except Exception as exc:
|
||||
raise HifiApiError(f"track_id must be int-compatible: {exc}") from exc
|
||||
if track_int <= 0:
|
||||
raise HifiApiError("track_id must be positive")
|
||||
|
||||
return self._get_json("lyrics/", params={"id": track_int})
|
||||
|
||||
Reference in New Issue
Block a user