Listing user libraries for radio

This commit is contained in:
localhost_frssoft 2022-11-08 03:29:44 +03:00
parent 474235d9e2
commit 5184f81277
2 changed files with 23 additions and 3 deletions

View file

@ -51,6 +51,17 @@ def list_tracks(page=None, q=None, artist=None, album=None, favourites=None):
return r.json() return r.json()
def list_libraries(page=None, page_size=None, q=None, scope='all'):
params = {
'page': page,
'page_size': page_size,
'q': q,
'scope': scope,
}
r = requests.get(f'https://{instance}/api/v1/libraries', params)
return r.json()
# [FunkWhale radios] # [FunkWhale radios]
def get_radios(): def get_radios():
r = s.get(f'https://{instance}/api/v1/radios/radios/') r = s.get(f'https://{instance}/api/v1/radios/radios/')

View file

@ -1,4 +1,4 @@
from src.fw_api import s, get_radios, post_radio_session, get_track_radio, concatinate_endpoint from src.fw_api import s, get_radios, post_radio_session, get_track_radio, list_libraries, concatinate_endpoint
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
@ -34,7 +34,16 @@ def list_radios():
elif 'Random' in selected: elif 'Random' in selected:
radio_load(id_radio, 'random') radio_load(id_radio, 'random')
elif 'Library' in selected: elif 'Library' in selected:
print('Input library address (ex. example@example.example): ') libs = list_libraries()['results']
libraries_listing = []
for lib_i in libs:
lib_name = lib_i.get('actor').get('full_username')
if lib_name not in libraries_listing:
libraries_listing.append(lib_name)
libraries_listing.append('Custom')
lib_addr = fzf.prompt(libraries_listing)[0]
if lib_addr == 'Custom':
print('Input remote user library (ex. nick@funkwhale.domain.example: ')
lib_addr = input() lib_addr = input()
radio_load(None, 'actor-content', lib_addr, lib_addr) radio_load(None, 'actor-content', lib_addr, lib_addr)
elif 'Recently Added' in selected: elif 'Recently Added' in selected: