mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 03:19:21 +02:00
Fetch new instances from api.fediverse.observer
This commit is contained in:
parent
81f818bc2f
commit
c1d1c97698
|
@ -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 []
|
||||
|
|
Loading…
Reference in New Issue