Fetch new instances from api.fediverse.observer

This commit is contained in:
localhost_frssoft 2023-06-19 03:33:15 +03:00
parent 81f818bc2f
commit c1d1c97698

View file

@ -128,6 +128,29 @@ def get_new_funkwhale_servers():
for i in new_instances_list:
if i[0] not in exists_instances and i[1]:
new_instances.append(i[0])
new_instances.extend(get_new_funkwhale_servers_fediverse_observer())
new_instances = list(dict.fromkeys(new_instances))
return new_instances
except: # If any errors then return empty list
return []
def get_new_funkwhale_servers_fediverse_observer():
try:
graphQL_request = {
'query':
'{\n nodes(softwarename: \"funkwhale\") {\n domain\n metanodeinfo\n }\n}'
}
r = requests.post('https://api.fediverse.observer/',
headers={'Accept-Encoding': 'gzip, deflate'},
json=graphQL_request)
new_instances = []
exists_instances = get_config('public_list_instances')
for i in r.json()['data']['nodes']:
if i.get('metanodeinfo'):
auth_no_required = json.loads(i['metanodeinfo'])['library']['anonymousCanListen']
if auth_no_required and i['domain'] not in exists_instances:
new_instances.append(i['domain'])
return new_instances
except:
return []