From d39a86a2a9abd5f70f8119f23a705d6e14ecf581 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 12 Jun 2023 03:18:58 +0300 Subject: [PATCH] More verbose info about instance --- funkwhale_cli.py | 30 ++++++++++++++++++++++++++---- src/fw_api.py | 4 +++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/funkwhale_cli.py b/funkwhale_cli.py index ec4dc80..ded8951 100755 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -34,18 +34,28 @@ def main(): 'Favorites', 'Recently listened', 'Search', + 'About instance', 'Switch instance'] try: - ins_settings = get_instance_settings() + ins_settings, ins_nodeinfo = get_instance_settings() for i in ins_settings: if i.get('name') == 'support_message': support_message = i.get('value') if i.get('name') == 'name': instance_title = i.get('value') - main_menu_header = quote(f'''{instance_title}'''.strip()) - except: + instance_stats = [] + for k, v in ins_nodeinfo['metadata']['library'].items(): + if k == 'anonymousCanListen' and v == False: + instance_stats.append(f'!!! {k}: {v} !!!') + continue + instance_stats.append(f'{k}: {v}') + instance_stats.append(ins_nodeinfo['software']['version']) + instance_stats = '\n'.join(instance_stats) + + main_menu_header = quote(f'''{instance_title}\n{instance_stats}'''.strip()) + except Exception as E: time.sleep(1) - main_menu_header = quote(f'''Connection failed'''.strip()) + main_menu_header = quote(f'''Connection failed: {E}'''.strip()) menu = ['Switch instance'] if not current_instance.s.headers.get('Authorization'): @@ -114,6 +124,18 @@ Insert token from "Access token" here''') print('Support instance message:') print(support_message) input() + if selected == 'About instance': + for i in ins_settings: + k, v = i.get('verbose_name'), i.get('value') + print(f'{k}: {v}') + print('|||||Some stats:') + for k, v in ins_nodeinfo['metadata']['usage'].items(): + print(f'{k}: {v}') + for k, v in ins_nodeinfo['metadata']['library'].items(): + print(f'{k}: {v}') + for k, v in ins_nodeinfo['usage'].items(): + print(f'{k}: {v}') + input() if selected == 'Player': src.mpv_control.player_menu( storage=src.mpv_control.player_fw_storage.storage) diff --git a/src/fw_api.py b/src/fw_api.py index 0cd0f20..385a442 100644 --- a/src/fw_api.py +++ b/src/fw_api.py @@ -72,7 +72,9 @@ def get_me(): def get_instance_settings(): r = current_instance.s.get( f'https://{current_instance.instance}/api/v1/instance/settings') - return r.json() + r_node = current_instance.s.get( + f'https://{current_instance.instance}/api/v1/instance/nodeinfo/2.0/') + return r.json(), r_node.json() @logger.catch