20 lines
526 B
Python
20 lines
526 B
Python
"""
|
|
Utility methods for the Spotify query API
|
|
"""
|
|
from typing import Iterable
|
|
|
|
from spotify_model import Paging, SearchAlbum
|
|
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(limit: int, offset: int) -> Paging:
|
|
return Paging(**client.search(search_str, limit=limit, offset=offset, type="album")["albums"])
|
|
|
|
for item in exhaust(_search):
|
|
yield SearchAlbum(**item)
|