Add a function for querying labels
This commit is contained in:
parent
a783edd3ac
commit
238c052668
@ -5,7 +5,7 @@ Find an album using the `spotify_actions` API and echo its contents.
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from spotify_actions.echo import echo_album
|
from spotify_actions.echo import echo_album
|
||||||
from spotify_actions.search import search_album
|
from spotify_actions.search import search_albums
|
||||||
from spotify_actions.util import read_credentials
|
from spotify_actions.util import read_credentials
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ def main() -> None: # pylint: disable=missing-function-docstring
|
|||||||
|
|
||||||
client = read_credentials(cmdline.config)
|
client = read_credentials(cmdline.config)
|
||||||
|
|
||||||
albums = search_album(client, cmdline.search_string)
|
albums = search_albums(client, cmdline.search_string)
|
||||||
echo_album(albums)
|
echo_album(albums)
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,11 +9,22 @@ from spotipy import Spotify
|
|||||||
from .util import exhaust
|
from .util import exhaust
|
||||||
|
|
||||||
|
|
||||||
def search_album(client: Spotify, search_str: str) -> Iterable[SearchAlbum]:
|
def _search_albums(client: Spotify, search_str: str) -> Paging:
|
||||||
"Display albums from a search string"
|
|
||||||
|
|
||||||
def _search(limit: int, offset: int) -> Paging:
|
def _search(limit: int, offset: int) -> Paging:
|
||||||
return Paging(**client.search(search_str, limit=limit, offset=offset, type="album")["albums"])
|
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)
|
yield SearchAlbum(**item)
|
||||||
|
Loading…
Reference in New Issue
Block a user