mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2025-05-04 02:48:40 +00:00
Libraries filter now avalaible in artists, albums, tracks
This commit is contained in:
parent
8fa1773807
commit
dae0516052
6 changed files with 81 additions and 17 deletions
|
@ -1,12 +1,13 @@
|
|||
from src.fw_api import list_libraries
|
||||
from src.fw_api import list_libraries, federate_remote_library, scan_remote_library
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
import time
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def libraries(pg=None):
|
||||
def libraries(pg=None, radio=False):
|
||||
libs_res = list_libraries(pg=pg)
|
||||
libs_count = libs_res.get('count')
|
||||
libs_next = libs_res.get('next')
|
||||
|
@ -17,6 +18,9 @@ def libraries(pg=None):
|
|||
libraries_listing.append('Next')
|
||||
if libs_prev:
|
||||
libraries_listing.append('Prev')
|
||||
if radio == False:
|
||||
libraries_listing.append('Add remote library')
|
||||
|
||||
for lib_i in libs:
|
||||
index = libs.index(lib_i)
|
||||
lib_name = lib_i.get('name')
|
||||
|
@ -28,8 +32,33 @@ def libraries(pg=None):
|
|||
return libraries(pg=libs_next)
|
||||
elif lib_select[0] == 'Prev':
|
||||
return libraries(pg=libs_prev)
|
||||
elif lib_select[0] == 'Add remote library':
|
||||
print('Search a remote library (url\\fid):')
|
||||
new_library = federate_remote_library(input())
|
||||
if new_library.get('detail'):
|
||||
logger.error(new_library['detail'])
|
||||
return
|
||||
if new_library.get('count') > 0:
|
||||
print('Library found')
|
||||
one_lib = new_library['results'][0]
|
||||
scan = scan_remote_library(one_lib['uuid'])
|
||||
if scan.get('detail'):
|
||||
logger.error(scan['detail'])
|
||||
return
|
||||
status = scan['status']
|
||||
if status == 'scheduled':
|
||||
print(f'Scanning {status}. Please wait few minutes for scan and open libraries menu again')
|
||||
else:
|
||||
print(f'Scan is {status}')
|
||||
time.sleep(3)
|
||||
return
|
||||
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
|
||||
lib_uuid = libs[int(lib_addr)]['uuid']
|
||||
lib_fid = libs[int(lib_addr)]['fid']
|
||||
if radio:
|
||||
return None, 'library', f'{lib_name}\n{lib_fid}', lib_uuid
|
||||
else:
|
||||
return lib_uuid
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue