Add search by artists, albums

This commit is contained in:
localhost_frssoft 2022-11-09 00:24:59 +03:00
parent b2becd9bd2
commit f3762e2a4e
3 changed files with 13 additions and 6 deletions

View File

@ -7,6 +7,7 @@ Features:
* Listen radios (include users/libraries) * Listen radios (include users/libraries)
* Select and listen albums * Select and listen albums
* Select and listen artists * Select and listen artists
* Search by albums, artists
* Switch instance from public list in config.json[1].. * Switch instance from public list in config.json[1]..
* All others features maybe working 50/50 * All others features maybe working 50/50

View File

@ -7,19 +7,19 @@ from loguru import logger
fzf = FzfPrompt() fzf = FzfPrompt()
@logger.catch @logger.catch
def list_albums(albums=None, pg=None): def list_albums(albums=None, pg=None, search=None):
albums_next = None albums_next = None
albums_prev = None albums_prev = None
play_artist_albums = False play_artist_albums = False
if not albums: if not albums:
albums = get_albums(pg=pg) albums = get_albums(q=search, pg=pg)
albums_next = albums.get('next') albums_next = albums.get('next')
albums_prev = albums.get('previous') albums_prev = albums.get('previous')
albums_results = albums.get('results') albums_results = albums.get('results')
else: else:
play_artist_albums = True play_artist_albums = True
albums_results = albums albums_results = albums
view = [] view = ['Search']
if play_artist_albums: if play_artist_albums:
view.append('Play all') view.append('Play all')
if albums_next: if albums_next:
@ -36,6 +36,9 @@ def list_albums(albums=None, pg=None):
list_albums(pg=albums_next) list_albums(pg=albums_next)
elif select == 'Prev page': elif select == 'Prev page':
list_albums(pg=albums_prev) list_albums(pg=albums_prev)
elif select == 'Search':
print('Search by albums: ')
list_albums(search=input())
elif select == 'Play all': elif select == 'Play all':
src.fw_artists.play_artist(albums_results[0].get('artist')) src.fw_artists.play_artist(albums_results[0].get('artist'))
else: else:

View File

@ -7,12 +7,12 @@ from loguru import logger
fzf = FzfPrompt() fzf = FzfPrompt()
@logger.catch @logger.catch
def list_artists(pg=None): def list_artists(pg=None, search=None):
artists = get_artists(pg=pg) artists = get_artists(q=search,pg=pg)
artists_next = artists.get('next') artists_next = artists.get('next')
artists_prev = artists.get('previous') artists_prev = artists.get('previous')
artists_results = artists.get('results') artists_results = artists.get('results')
view = [] view = ['Search']
if artists_next: if artists_next:
view.append('Next page') view.append('Next page')
if artists_prev: if artists_prev:
@ -27,6 +27,9 @@ def list_artists(pg=None):
list_artists(pg=artists_next) list_artists(pg=artists_next)
elif select == 'Prev page': elif select == 'Prev page':
list_artists(pg=artists_prev) list_artists(pg=artists_prev)
elif select == 'Search':
print('Search by artist:')
list_artists(search=input())
else: else:
list_albums(albums=artists_results[int(select)].get('albums')) list_albums(albums=artists_results[int(select)].get('albums'))