From 4efed21d3f7784fe861ee54c950e83e88e3b7b24 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 15 Jun 2023 23:53:31 +0300 Subject: [PATCH 1/3] Separate getting node info and instance settings (for fast starting) --- funkwhale_cli.py | 12 +++++------- src/fw_api.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/funkwhale_cli.py b/funkwhale_cli.py index 2bb36bf..b629c67 100755 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from src.fw_api import current_instance, get_instance_settings +from src.fw_api import current_instance, get_instance_settings, get_node_info from src.fw_radios import list_radios from src.fw_artists import list_artists from src.fw_albums import list_albums @@ -34,12 +34,9 @@ def main(): 'About instance', 'Switch instance'] try: - 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') + ins_nodeinfo = get_node_info() + support_message = ins_nodeinfo['metadata']['instanceSupportMessage'] + instance_title = ins_nodeinfo['metadata']['nodeName'] instance_stats = [] for k, v in ins_nodeinfo['metadata']['library'].items(): if k == 'anonymousCanListen' and v == False and not current_instance.s.headers.get('Authorization'): @@ -130,6 +127,7 @@ Insert token from "Access token" here''') if selected == 'Donate': os.system(f'less < Date: Thu, 15 Jun 2023 23:55:45 +0300 Subject: [PATCH 2/3] Added funkwhale ASCII icon when starting --- .icon.txt | 14 ++++++++++++++ funkwhale_cli.py | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 .icon.txt diff --git a/.icon.txt b/.icon.txt new file mode 100644 index 0000000..0693000 --- /dev/null +++ b/.icon.txt @@ -0,0 +1,14 @@ + .'''... ..''''. + '''''''......''''''' + ''''''''''''''. + .''''. + .''. + .''. +:u, 'uu .uu. .uu. :u' .uu +.oo oo, uo;'';oo. .oo uo, + :o; uo;. .,oo ;ou + :o:. uo;'......';oo ;o: + .ou,. ,oooo; .,uo. + :o:,.. ..':ou + oou:;;;;:uoo + 'uu' diff --git a/funkwhale_cli.py b/funkwhale_cli.py index b629c67..d5dbfb2 100755 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -13,10 +13,15 @@ import src.mpv_control import json import os from shlex import quote +from shutil import get_terminal_size from pyfzf.pyfzf import FzfPrompt fzf = FzfPrompt() +os.system('clear') +if get_terminal_size().columns > 32: + print('\n\n') + os.system('cat .icon.txt') def main(): From 765f5a192d6265b38ce598de591b479c55c34b42 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Fri, 16 Jun 2023 02:22:52 +0300 Subject: [PATCH 3/3] indent for auth file --- funkwhale_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/funkwhale_cli.py b/funkwhale_cli.py index d5dbfb2..fb873dc 100755 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -119,10 +119,10 @@ Read | Write (optional): Insert token from "Access token" here''') register_token = input() with open('.auth.json', 'rt') as f: - tkns = json.loads(f.read()) + tkns = json.load(f) with open('.auth.json', 'wt') as f: tkns[current_instance.instance] = register_token - f.write(json.dumps(tkns)) + f.write(json.dumps(tkns, indent=4)) del tkns del register_token del f