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)
* 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

View file

@ -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:

View file

@ -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'))