mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-25 14:11:26 +00:00
Some fixes in radios
This commit is contained in:
parent
f5840926a6
commit
a76f36bafd
|
@ -15,7 +15,7 @@ fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_radios():
|
def list_radios(error_given=None):
|
||||||
radios = get_radios()
|
radios = get_radios()
|
||||||
count = radios.get('count')
|
count = radios.get('count')
|
||||||
|
|
||||||
|
@ -35,9 +35,12 @@ def list_radios():
|
||||||
view.append('Favourites')
|
view.append('Favourites')
|
||||||
view.append('Less listened')
|
view.append('Less listened')
|
||||||
view.extend(['Tag', 'Random', 'Libraries', 'Users', 'Recently Added'])
|
view.extend(['Tag', 'Random', 'Libraries', 'Users', 'Recently Added'])
|
||||||
|
header = f'Found {count} radios'
|
||||||
|
if error_given:
|
||||||
|
header += f'\n{error_given}'
|
||||||
|
header = quote(header)
|
||||||
selected = fzf.prompt(
|
selected = fzf.prompt(
|
||||||
view, f'--header \'Found {count} radios\' --read0', delimiter="\0")[0].split('.', 1)
|
view, f'--header {header} --read0', delimiter="\0")[0].split('.', 1)
|
||||||
if 'Favourites' in selected:
|
if 'Favourites' in selected:
|
||||||
radio_load(id_radio, 'favorites', name='your favorites tracks')
|
radio_load(id_radio, 'favorites', name='your favorites tracks')
|
||||||
elif 'Tag' in selected:
|
elif 'Tag' in selected:
|
||||||
|
@ -104,7 +107,10 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
||||||
}
|
}
|
||||||
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, 2):
|
for i in range(0, 2):
|
||||||
radio_get_track(radio_session_id)
|
try:
|
||||||
|
radio_get_track(radio_session_id, first_run=True)
|
||||||
|
except Exception as E:
|
||||||
|
return list_radios(error_given=f'Error: {E}')
|
||||||
|
|
||||||
radio_event_gen.set()
|
radio_event_gen.set()
|
||||||
radio_task = threading.Thread(
|
radio_task = threading.Thread(
|
||||||
|
@ -121,8 +127,12 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
||||||
player_items_menu[2] = 'Play'
|
player_items_menu[2] = 'Play'
|
||||||
else:
|
else:
|
||||||
player_items_menu[2] = 'Pause'
|
player_items_menu[2] = 'Pause'
|
||||||
|
try:
|
||||||
select = fzf.prompt(player_items_menu,
|
select = fzf.prompt(player_items_menu,
|
||||||
quote(f"--header=\'Radio {name} playing...\'"))[0]
|
quote(f"--header=\'Radio {name} playing...\'"))[0]
|
||||||
|
except:
|
||||||
|
select = 'Exit'
|
||||||
|
|
||||||
if select == 'Next':
|
if select == 'Next':
|
||||||
playlist_remaining = player.playlist_count - player.playlist_current_pos
|
playlist_remaining = player.playlist_count - player.playlist_current_pos
|
||||||
if playlist_remaining <= 2:
|
if playlist_remaining <= 2:
|
||||||
|
@ -169,7 +179,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def radio_get_track(radio_session_id):
|
def radio_get_track(radio_session_id, first_run=False):
|
||||||
radio_context = get_track_radio({'session': radio_session_id})
|
radio_context = get_track_radio({'session': radio_session_id})
|
||||||
if not radio_context:
|
if not radio_context:
|
||||||
return
|
return
|
||||||
|
@ -177,6 +187,9 @@ def radio_get_track(radio_session_id):
|
||||||
logger.error(radio_context)
|
logger.error(radio_context)
|
||||||
if radio_context == "Radio doesn't have more candidates":
|
if radio_context == "Radio doesn't have more candidates":
|
||||||
radio_event_gen.clear()
|
radio_event_gen.clear()
|
||||||
|
if first_run:
|
||||||
|
radio_context = 'This radio may be private or haven\'t tracks'
|
||||||
|
raise IOError(radio_context)
|
||||||
return
|
return
|
||||||
if radio_context.get('error'):
|
if radio_context.get('error'):
|
||||||
logger.error(radio_context.get('error'))
|
logger.error(radio_context.get('error'))
|
||||||
|
|
Loading…
Reference in a new issue