Fixes QobuzDL search
This commit is contained in:
@@ -17,6 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
MEDIA_CLASS = {"album": Album, "playlist": Playlist, "artist": Artist}
|
||||
Media = Union[Album, Playlist, Artist] # type hint
|
||||
|
||||
|
||||
class QobuzDL:
|
||||
@@ -87,5 +88,8 @@ class QobuzDL:
|
||||
|
||||
raise ParsingError("Error parsing URLs from file `{filepath}`")
|
||||
|
||||
def search(self, query: str, media_type: str, limit: int = 200) -> Generator:
|
||||
return self.client.search(query, media_type, limit)
|
||||
def search(self, query: str, media_type: str, limit: int = 200) -> Media:
|
||||
results = self.client.search(query, media_type, limit)
|
||||
for page in results:
|
||||
for item in page[f"{media_type}s"]["items"]:
|
||||
yield MEDIA_CLASS[media_type].from_api(item, self.client)
|
||||
|
||||
@@ -613,6 +613,7 @@ class Artist(Tracklist):
|
||||
:param source: in ('qobuz', 'deezer', 'tidal')
|
||||
:type source: str
|
||||
"""
|
||||
logging.debug("Loading item from API")
|
||||
if source in ("qobuz", "deezer"):
|
||||
info = {
|
||||
"name": item.get("name"),
|
||||
@@ -625,8 +626,9 @@ class Artist(Tracklist):
|
||||
}
|
||||
else:
|
||||
raise ValueError(f"invalid source '{source}'")
|
||||
logging.debug(f"Loaded info {info}")
|
||||
|
||||
# equivalent to Album(client=client, **info)
|
||||
# equivalent to Artist(client=client, **info)
|
||||
return cls(client=client, **info)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user