mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 16:51:27 +00:00
Users by libraries and libraries added in radio
This commit is contained in:
parent
e07a672466
commit
7e936d9bbb
|
@ -93,15 +93,18 @@ def get_albums(page=None, q=None, artist=None, pg=None):
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
@logger.catch
|
||||||
def list_libraries(page=None, page_size=None, q=None, scope='all'):
|
def list_libraries(page=None, page_size=None, q=None, scope='all', pg=None):
|
||||||
params = {
|
params = {
|
||||||
'page': page,
|
'page': page,
|
||||||
'page_size': page_size,
|
'page_size': page_size,
|
||||||
'q': q,
|
'q': q,
|
||||||
'scope': scope,
|
'scope': scope,
|
||||||
}
|
}
|
||||||
r = s.get(f'https://{instance}/api/v1/libraries', params)
|
if pg:
|
||||||
|
r = s.get(pg)
|
||||||
|
else:
|
||||||
|
r = s.get(f'https://{instance}/api/v1/libraries', params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ fzf = FzfPrompt()
|
||||||
|
|
||||||
audio_info = {}
|
audio_info = {}
|
||||||
|
|
||||||
|
@logger.catch
|
||||||
def list_radios():
|
def list_radios():
|
||||||
radios = get_radios()
|
radios = get_radios()
|
||||||
count = radios.get('count')
|
count = radios.get('count')
|
||||||
|
@ -25,7 +26,8 @@ def list_radios():
|
||||||
view.append('Favourites')
|
view.append('Favourites')
|
||||||
view.append('Less listened')
|
view.append('Less listened')
|
||||||
view.append('Random')
|
view.append('Random')
|
||||||
view.append('Library')
|
view.append('Libraries')
|
||||||
|
view.append('Users')
|
||||||
view.append('Recently Added')
|
view.append('Recently Added')
|
||||||
|
|
||||||
selected = fzf.prompt(view, f'--header \'Found {count} radios\'')[0].split('.', 1)
|
selected = fzf.prompt(view, f'--header \'Found {count} radios\'')[0].split('.', 1)
|
||||||
|
@ -33,7 +35,34 @@ def list_radios():
|
||||||
radio_load(id_radio, 'favorites')
|
radio_load(id_radio, 'favorites')
|
||||||
elif 'Random' in selected:
|
elif 'Random' in selected:
|
||||||
radio_load(id_radio, 'random')
|
radio_load(id_radio, 'random')
|
||||||
elif 'Library' in selected:
|
elif 'Libraries' in selected:
|
||||||
|
def libraries(pg=None):
|
||||||
|
libs_res = list_libraries(pg=pg)
|
||||||
|
libs_count = libs_res.get('count')
|
||||||
|
libs_next = libs_res.get('next')
|
||||||
|
libs_prev = libs_res.get('previous')
|
||||||
|
libs = list_libraries()['results']
|
||||||
|
libraries_listing = []
|
||||||
|
if libs_next:
|
||||||
|
libraries_listing.append('Next')
|
||||||
|
if libs_prev:
|
||||||
|
libraries_listing.append('Prev')
|
||||||
|
for lib_i in libs:
|
||||||
|
index = libs.index(lib_i)
|
||||||
|
lib_name = lib_i.get('name')
|
||||||
|
libraries_listing.append(f'{index}.{lib_name}')
|
||||||
|
lib_select = fzf.prompt(libraries_listing, f'--header=\'found {libs_count} libraries\'')[0].split('.', 1)
|
||||||
|
if lib_select[0] == 'Next':
|
||||||
|
libraries(pg=libs_next)
|
||||||
|
elif lib_select[0] == 'Prev':
|
||||||
|
libraries(pg=libs_prev)
|
||||||
|
else:
|
||||||
|
lib_addr = lib_select[0]
|
||||||
|
lib_name = lib_select[1]
|
||||||
|
lib_uuid = libs[int(lib_addr)].get('uuid')
|
||||||
|
radio_load(None, 'library', lib_name, lib_uuid)
|
||||||
|
libraries()
|
||||||
|
elif 'Users' in selected:
|
||||||
libs = list_libraries()['results']
|
libs = list_libraries()['results']
|
||||||
libraries_listing = []
|
libraries_listing = []
|
||||||
for lib_i in libs:
|
for lib_i in libs:
|
||||||
|
|
Loading…
Reference in a new issue