From f3762e2a4eaf072e9453cb0c81c7c6497e340d5d Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 9 Nov 2022 00:24:59 +0300 Subject: [PATCH] Add search by artists, albums --- README.md | 1 + src/fw_albums.py | 9 ++++++--- src/fw_artists.py | 9 ++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3ac436b..17ca226 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Features: * Listen radios (include users/libraries) * Select and listen albums * Select and listen artists +* Search by albums, artists * Switch instance from public list in config.json[1].. * All others features maybe working 50/50 diff --git a/src/fw_albums.py b/src/fw_albums.py index b128c96..bfc9917 100644 --- a/src/fw_albums.py +++ b/src/fw_albums.py @@ -7,19 +7,19 @@ from loguru import logger fzf = FzfPrompt() @logger.catch -def list_albums(albums=None, pg=None): +def list_albums(albums=None, pg=None, search=None): albums_next = None albums_prev = None play_artist_albums = False if not albums: - albums = get_albums(pg=pg) + albums = get_albums(q=search, pg=pg) albums_next = albums.get('next') albums_prev = albums.get('previous') albums_results = albums.get('results') else: play_artist_albums = True albums_results = albums - view = [] + view = ['Search'] if play_artist_albums: view.append('Play all') if albums_next: @@ -36,6 +36,9 @@ def list_albums(albums=None, pg=None): list_albums(pg=albums_next) elif select == 'Prev page': list_albums(pg=albums_prev) + elif select == 'Search': + print('Search by albums: ') + list_albums(search=input()) elif select == 'Play all': src.fw_artists.play_artist(albums_results[0].get('artist')) else: diff --git a/src/fw_artists.py b/src/fw_artists.py index 4f680cf..ab82397 100644 --- a/src/fw_artists.py +++ b/src/fw_artists.py @@ -7,12 +7,12 @@ from loguru import logger fzf = FzfPrompt() @logger.catch -def list_artists(pg=None): - artists = get_artists(pg=pg) +def list_artists(pg=None, search=None): + artists = get_artists(q=search,pg=pg) artists_next = artists.get('next') artists_prev = artists.get('previous') artists_results = artists.get('results') - view = [] + view = ['Search'] if artists_next: view.append('Next page') if artists_prev: @@ -27,6 +27,9 @@ def list_artists(pg=None): list_artists(pg=artists_next) elif select == 'Prev page': list_artists(pg=artists_prev) + elif select == 'Search': + print('Search by artist:') + list_artists(search=input()) else: list_albums(albums=artists_results[int(select)].get('albums'))