Add a function for querying labels
This commit is contained in:
@ -9,11 +9,22 @@ from spotipy import Spotify
|
||||
from .util import exhaust
|
||||
|
||||
|
||||
def search_album(client: Spotify, search_str: str) -> Iterable[SearchAlbum]:
|
||||
"Display albums from a search string"
|
||||
|
||||
def _search_albums(client: Spotify, search_str: str) -> Paging:
|
||||
def _search(limit: int, offset: int) -> Paging:
|
||||
return Paging(**client.search(search_str, limit=limit, offset=offset, type="album")["albums"])
|
||||
|
||||
for item in exhaust(_search):
|
||||
return _search
|
||||
|
||||
|
||||
def search_albums(client: Spotify, search_str: str) -> Iterable[SearchAlbum]:
|
||||
"Display albums from a search string"
|
||||
|
||||
for item in exhaust(_search_albums(client, search_str)):
|
||||
yield SearchAlbum(**item)
|
||||
|
||||
|
||||
def search_label_albums(client: Spotify, search_str: str) -> Iterable[SearchAlbum]:
|
||||
"Display albums from a particular label"
|
||||
|
||||
for item in exhaust(_search_albums(client, f'label:"{search_str}"')):
|
||||
yield SearchAlbum(**item)
|
||||
|
Reference in New Issue
Block a user