mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 04:29:19 +02:00
Separate getting node info and instance settings (for fast starting)
This commit is contained in:
parent
3c545cc991
commit
4efed21d3f
|
@ -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 <<EOF\nSupport instance message:\n{support_message}\nEOF')
|
||||
if selected == 'About instance':
|
||||
ins_settings = get_instance_settings()
|
||||
about_instance_info = []
|
||||
for i in ins_settings:
|
||||
k, v = i.get('verbose_name'), i.get('value')
|
||||
|
|
|
@ -62,6 +62,7 @@ def get_me():
|
|||
if not current_instance.token:
|
||||
return
|
||||
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/users/me')
|
||||
r.raise_for_status()
|
||||
resp = r.json()
|
||||
current_instance.listen_token = resp['tokens']['listen']
|
||||
return resp
|
||||
|
@ -70,9 +71,14 @@ def get_me():
|
|||
def get_instance_settings():
|
||||
r = current_instance.s.get(
|
||||
f'https://{current_instance.instance}/api/v1/instance/settings')
|
||||
r_node = current_instance.s.get(
|
||||
return r.json()
|
||||
|
||||
|
||||
def get_node_info():
|
||||
r = current_instance.s.get(
|
||||
f'https://{current_instance.instance}/api/v1/instance/nodeinfo/2.0/')
|
||||
return r.json(), r_node.json()
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
|
|
Loading…
Reference in New Issue