mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 17:43:02 +00:00
Radio of favourites tracks
This commit is contained in:
parent
8f805009db
commit
f582c15c77
@ -19,10 +19,16 @@ def list_radios():
|
|||||||
name = i.get('name')
|
name = i.get('name')
|
||||||
view.append(f'{index}.{name}')
|
view.append(f'{index}.{name}')
|
||||||
|
|
||||||
|
view.append('Favourites')
|
||||||
|
|
||||||
selected = fzf.prompt(view, f'--header \'Found {count} radios\'')[0].split('.', 1)
|
selected = fzf.prompt(view, f'--header \'Found {count} radios\'')[0].split('.', 1)
|
||||||
id_selected = selected[0]
|
if 'Favourites' in selected:
|
||||||
id_radio = results[int(id_selected)].get('id')
|
type_radio = 'favorites'
|
||||||
radio_load(id_radio)
|
radio_load(id_radio, type_radio)
|
||||||
|
else:
|
||||||
|
id_selected = selected[0]
|
||||||
|
id_radio = results[int(id_selected)].get('id')
|
||||||
|
radio_load(id_radio)
|
||||||
|
|
||||||
|
|
||||||
def radio_generator(radio_session_id):
|
def radio_generator(radio_session_id):
|
||||||
@ -31,14 +37,14 @@ def radio_generator(radio_session_id):
|
|||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
def radio_load(id_radio):
|
def radio_load(id_radio=None, type_radio='custom'):
|
||||||
requested_radio = {
|
requested_radio = {
|
||||||
'custom_radio': id_radio,
|
'custom_radio': id_radio,
|
||||||
'radio_type': 'custom',
|
'radio_type': type_radio,
|
||||||
'related_object_id': None
|
'related_object_id': None
|
||||||
}
|
}
|
||||||
radio_session_id = post_radio_session(requested_radio).get('id')
|
radio_session_id = post_radio_session(requested_radio).get('id')
|
||||||
for i in range(0, 10):
|
for i in range(0, 5):
|
||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
|
|
||||||
player.playlist_pos = 0
|
player.playlist_pos = 0
|
||||||
@ -46,7 +52,6 @@ def radio_load(id_radio):
|
|||||||
radio_task.start()
|
radio_task.start()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
print(len(player.playlist))
|
|
||||||
select = fzf.prompt(('Next', 'Prev', 'Pause', 'Exit'), f'--header=\'Radio playing...\'')[0]
|
select = fzf.prompt(('Next', 'Prev', 'Pause', 'Exit'), f'--header=\'Radio playing...\'')[0]
|
||||||
if select == 'Next':
|
if select == 'Next':
|
||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
@ -72,8 +77,12 @@ def radio_load(id_radio):
|
|||||||
|
|
||||||
def radio_get_track(radio_session_id):
|
def radio_get_track(radio_session_id):
|
||||||
radio_context = get_track_radio({'session': radio_session_id})
|
radio_context = get_track_radio({'session': radio_session_id})
|
||||||
track = radio_context.get('track')
|
|
||||||
listen_url = track.get('listen_url')
|
if radio_context == "Radio doesn't have more candidates":
|
||||||
player.playlist_append(concatinate_endpoint(listen_url))
|
return
|
||||||
|
else:
|
||||||
|
track = radio_context.get('track')
|
||||||
|
listen_url = track.get('listen_url')
|
||||||
|
player.playlist_append(concatinate_endpoint(listen_url))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user