mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 15:59:21 +02:00
Libraries separated
This commit is contained in:
parent
f3762e2a4e
commit
ff26263496
|
@ -0,0 +1,33 @@
|
||||||
|
from src.fw_api import list_libraries
|
||||||
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
||||||
|
return None, 'library', lib_name, lib_uuid
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from src.fw_api import s, get_radios, post_radio_session, get_track_radio, list_libraries, concatinate_endpoint
|
from src.fw_api import s, get_radios, post_radio_session, get_track_radio, list_libraries, concatinate_endpoint
|
||||||
|
from src.fw_libraries import libraries
|
||||||
from src.utils import download_track
|
from src.utils import download_track
|
||||||
from src.mpv_control import player
|
from src.mpv_control import player
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
@ -36,32 +37,8 @@ def list_radios():
|
||||||
elif 'Random' in selected:
|
elif 'Random' in selected:
|
||||||
radio_load(id_radio, 'random')
|
radio_load(id_radio, 'random')
|
||||||
elif 'Libraries' in selected:
|
elif 'Libraries' in selected:
|
||||||
def libraries(pg=None):
|
id_radio, type_radio, name_radio, related_obj = libraries()
|
||||||
libs_res = list_libraries(pg=pg)
|
radio_load(id_radio, type_radio, name_radio, related_obj)
|
||||||
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:
|
elif 'Users' in selected:
|
||||||
libs = list_libraries()['results']
|
libs = list_libraries()['results']
|
||||||
libraries_listing = []
|
libraries_listing = []
|
||||||
|
|
Loading…
Reference in New Issue