Compare commits

...

2 commits

Author SHA1 Message Date
localhost_frssoft 9f37a52a64 Fix some checks when try connect 2023-06-13 01:58:52 +03:00
localhost_frssoft 03ff52fcec albums tracks count 2023-06-12 14:47:45 +03:00
3 changed files with 8 additions and 7 deletions

View file

@ -45,8 +45,9 @@ def main():
instance_title = i.get('value') instance_title = i.get('value')
instance_stats = [] instance_stats = []
for k, v in ins_nodeinfo['metadata']['library'].items(): for k, v in ins_nodeinfo['metadata']['library'].items():
if k == 'anonymousCanListen' and v == False: if k == 'anonymousCanListen' and v == False and not current_instance.s.headers.get('Authorization'):
instance_stats.append(f'!!! {k}: {v} !!!') instance_stats.append(f'!!! {k}: {v} !!!')
menu = ['Switch instance', 'About instance']
continue continue
instance_stats.append(f'{k}: {v}') instance_stats.append(f'{k}: {v}')
instance_stats.append(ins_nodeinfo['software']['version']) instance_stats.append(ins_nodeinfo['software']['version'])
@ -54,8 +55,8 @@ def main():
main_menu_header = quote(f'''{instance_title}\n{instance_stats}'''.strip()) main_menu_header = quote(f'''{instance_title}\n{instance_stats}'''.strip())
except Exception as E: except Exception as E:
time.sleep(1) splitted = ':\n'.join(str(E).split(':'))
main_menu_header = quote(f'''Connection failed: {E}'''.strip()) main_menu_header = quote(f'''Connection failed:\n{splitted}'''.strip())
menu = ['Switch instance'] menu = ['Switch instance']
if not current_instance.s.headers.get('Authorization'): if not current_instance.s.headers.get('Authorization'):

View file

@ -37,13 +37,14 @@ def list_albums(albums=None, pg=None, search=None, artist=None, library=None, in
for i in albums_results: for i in albums_results:
index = albums_results.index(i) index = albums_results.index(i)
album_name = i.get('title') album_name = i.get('title')
option_str = f'{index}.{album_name}' album_tracks_count = i.get('tracks_count')
option_str = f'{index}.{album_name} | {album_tracks_count}'
artist_name = i.get('artist') artist_name = i.get('artist')
if show_artist_name_in_albums and isinstance(artist_name, dict): if show_artist_name_in_albums and isinstance(artist_name, dict):
artist_name = artist_name.get('name') artist_name = artist_name.get('name')
option_str += f' | Artist: {artist_name}' option_str += f' | {artist_name}'
view.append(f'{option_str}') view.append(f'{option_str}')
select = fzf.prompt(view)[0].split('.', 1)[0] select = fzf.prompt(view, '--header=\'map: album | tracks count | opt. artist\'')[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

@ -68,7 +68,6 @@ def get_me():
return resp return resp
@logger.catch
def get_instance_settings(): def get_instance_settings():
r = current_instance.s.get( r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/instance/settings') f'https://{current_instance.instance}/api/v1/instance/settings')