Libraries menu changed

This commit is contained in:
localhost_frssoft 2023-06-14 18:34:26 +03:00
parent 4ab9f2db2d
commit c93a2f0ee5

View File

@ -1,4 +1,4 @@
from src.fw_api import list_libraries, federate_remote_library, scan_remote_library
from src.fw_api import current_instance, list_libraries, federate_remote_library, scan_remote_library
from pyfzf.pyfzf import FzfPrompt
from loguru import logger
import time
@ -18,16 +18,18 @@ def libraries(pg=None, radio=False):
libraries_listing.append('Next')
if libs_prev:
libraries_listing.append('Prev')
if radio == False:
if current_instance.s.headers.get('Authorization'):
libraries_listing.append('Add remote library')
for lib_i in libs:
index = libs.index(lib_i)
lib_name = lib_i.get('name')
lib_tracks_count = lib_i.get('uploads_count')
lib_by = lib_i.get('actor').get('full_username')
libraries_listing.append(f'{index}.{lib_name} | by {lib_by}')
libraries_listing.append(f'{index}.{lib_name} | {lib_by} | {lib_tracks_count}')
lib_select = fzf.prompt(
libraries_listing, f'--header=\'found {libs_count} libraries\'')[0].split('.', 1)
libraries_listing,
f'--header=\'found {libs_count} libraries\nmap: library name | owner | tracks count\'')[0].split('.', 1)
if lib_select[0] == 'Next':
return libraries(pg=libs_next)
elif lib_select[0] == 'Prev':
@ -61,4 +63,3 @@ def libraries(pg=None, radio=False):
return None, 'library', f'{lib_name}\n{lib_fid}', lib_uuid
else:
return lib_uuid