Compare commits

..

2 Commits

Author SHA1 Message Date
localhost_frssoft 27e697b9c1 fix playlist selector 2023-06-15 01:08:02 +03:00
localhost_frssoft 06b2ebacd1 Fix menus when exit ESC or CTRL+C
So... After a long time i did fix for some menus
Reduce errors hell in terminal
2023-06-15 00:52:34 +03:00
10 changed files with 62 additions and 12 deletions

View File

@ -62,9 +62,13 @@ def main():
menu.append('Donate') menu.append('Donate')
if src.mpv_control.player.playlist_playing_pos != -1: if src.mpv_control.player.playlist_playing_pos != -1:
menu.insert(0, 'Player') menu.insert(0, 'Player')
ids = fzf.prompt(menu, f"--header={main_menu_header}") selected = fzf.prompt(menu, f"--header={main_menu_header}")
if selected == []:
print('bye-bye :3')
break
else:
selected = selected[0]
selected = ids[0]
if selected == 'Radios': if selected == 'Radios':
list_radios() list_radios()
if selected == 'Artists': if selected == 'Artists':
@ -90,7 +94,12 @@ def main():
'public_list_instances') + public_server_list_instances 'public_list_instances') + public_server_list_instances
settings.set_config('public_list_instances', list_instances) settings.set_config('public_list_instances', list_instances)
instance = fzf.prompt(list_instances, instance = fzf.prompt(list_instances,
'--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))[0] '--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))
if instance == []:
continue
else:
instance = instance[0]
current_instance.select_instance(instance) current_instance.select_instance(instance)
if selected == 'Sign in': if selected == 'Sign in':
print(f''' print(f'''

View File

@ -44,7 +44,12 @@ def list_albums(albums=None, pg=None, search=None, artist=None, library=None, in
artist_name = artist_name.get('name') artist_name = artist_name.get('name')
option_str += f' | {artist_name}' option_str += f' | {artist_name}'
view.append(f'{option_str}') view.append(f'{option_str}')
select = fzf.prompt(view, '--header=\'map: album | tracks count | opt. artist\'')[0].split('.', 1)[0] select = fzf.prompt(view, '--header=\'map: album | tracks count | opt. artist\'')
if select == []:
return
else:
select = select[0].split('.', 1)[0]
if select == 'Next page': if select == 'Next page':
list_albums(pg=albums_next) list_albums(pg=albums_next)
elif select == 'Prev page': elif select == 'Prev page':

View File

@ -26,7 +26,12 @@ def list_artists(pg=None, search=None, library=None, scope=None):
artist_name = i.get('name') artist_name = i.get('name')
artist_tracks_count = i.get('tracks_count') artist_tracks_count = i.get('tracks_count')
view.append(f'{index}.{artist_name} | {artist_tracks_count}') view.append(f'{index}.{artist_name} | {artist_tracks_count}')
select = fzf.prompt(view, '--header=\'map: artist | tracks count\'')[0].split('.', 1)[0] select = fzf.prompt(view, '--header=\'map: artist | tracks count\'')
if select == []:
return
else:
select = select[0].split('.', 1)[0]
if select == 'Next page': if select == 'Next page':
list_artists(pg=artists_next) list_artists(pg=artists_next)
elif select == 'Prev page': elif select == 'Prev page':
@ -49,7 +54,6 @@ def list_artists(pg=None, search=None, library=None, scope=None):
play_artist(artists_results[int(select)]['id']) play_artist(artists_results[int(select)]['id'])
def play_artist(artist_id): def play_artist(artist_id):
tracks = get_tracks(artist=artist_id, include_channels=True, pg=None) tracks = get_tracks(artist=artist_id, include_channels=True, pg=None)
tracks_next = tracks.get('next') tracks_next = tracks.get('next')

View File

@ -22,7 +22,12 @@ def list_channels(pg=None, search=None):
index = channels_results.index(i) index = channels_results.index(i)
channel_name = i.get('artist').get('name') channel_name = i.get('artist').get('name')
view.append(f'{index}.{channel_name}') view.append(f'{index}.{channel_name}')
select = fzf.prompt(view)[0].split('.', 1)[0] select = fzf.prompt(view)[0].split('.', 1)
if select == []:
return
else:
select = select[0]
if select == 'Next page': if select == 'Next page':
list_channels(pg=channels_next) list_channels(pg=channels_next)
elif select == 'Prev page': elif select == 'Prev page':

View File

@ -29,7 +29,12 @@ def libraries(pg=None, radio=False):
libraries_listing.append(f'{index}.{lib_name} | {lib_by} | {lib_tracks_count}') libraries_listing.append(f'{index}.{lib_name} | {lib_by} | {lib_tracks_count}')
lib_select = fzf.prompt( lib_select = fzf.prompt(
libraries_listing, libraries_listing,
f'--header=\'found {libs_count} libraries\nmap: library name | owner | tracks count\'')[0].split('.', 1) f'--header=\'found {libs_count} libraries\nmap: library name | owner | tracks count\'')
if lib_select == []:
return
else:
lib_select = lib_select[0].split('.', 1)
if lib_select[0] == 'Next': if lib_select[0] == 'Next':
return libraries(pg=libs_next) return libraries(pg=libs_next)
elif lib_select[0] == 'Prev': elif lib_select[0] == 'Prev':

View File

@ -22,7 +22,12 @@ def list_playlists(pg=None, search=None):
index = playlists_results.index(i) index = playlists_results.index(i)
playlist_name = i.get('name') playlist_name = i.get('name')
view.append(f'{index}.{playlist_name}') view.append(f'{index}.{playlist_name}')
select = fzf.prompt(view)[0].split('.', 1)[0] select = fzf.prompt(view)
if select == []:
return
else:
select = select[0].split('.', 1)[0]
if select == 'Next page': if select == 'Next page':
list_playlists(pg=playlists_next) list_playlists(pg=playlists_next)
elif select == 'Prev page': elif select == 'Prev page':

View File

@ -40,7 +40,12 @@ def list_radios(error_given=None):
header += f'\n{error_given}' header += f'\n{error_given}'
header = quote(header) header = quote(header)
selected = fzf.prompt( selected = fzf.prompt(
view, f'--header {header} --read0', delimiter="\0")[0].split('.', 1) view, f'--header {header} --read0', delimiter="\0")
if selected == []:
return
else:
selected = selected[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:

View File

@ -30,6 +30,9 @@ def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False)
who_user = i['user'].get('username') who_user = i['user'].get('username')
view.append(f'{index}.{track_name} | {who_user}') view.append(f'{index}.{track_name} | {who_user}')
select = fzf.prompt(view, f'--multi --header=\'map: track title | who {action}\'') select = fzf.prompt(view, f'--multi --header=\'map: track title | who {action}\'')
if select == []:
return
if 'Next page' in select: if 'Next page' in select:
list_fav_or_history(pg=tracks_next, is_history_view=is_history_view) list_fav_or_history(pg=tracks_next, is_history_view=is_history_view)
elif 'Prev page' in select: elif 'Prev page' in select:

View File

@ -24,7 +24,11 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
index = tracks_results.index(i) index = tracks_results.index(i)
track_name = i.get('title') track_name = i.get('title')
view.append(f'{index}.{track_name}') view.append(f'{index}.{track_name}')
select = fzf.prompt(view)[0].split('.', 1)[0] select = fzf.prompt(view)
if select == []:
return
else:
select = select[0].split('.', 1)[0]
if select == 'Next page': if select == 'Next page':
list_tracks(pg=tracks_next) list_tracks(pg=tracks_next)
elif select == 'Prev page': elif select == 'Prev page':

View File

@ -138,7 +138,12 @@ def player_menu(header='', storage={}):
player_items_menu.append('Like') player_items_menu.append('Like')
player_items_menu.extend(['Hide artist', 'Exit']) player_items_menu.extend(['Hide artist', 'Exit'])
select = fzf.prompt(player_items_menu, quote(f"--header=\'{header}\'"))[0] select = fzf.prompt(player_items_menu, quote(f"--header=\'{header}\'"))
if select == []:
break
else:
select = select[0]
if select == 'Next': if select == 'Next':
try: try:
player.playlist_next() player.playlist_next()