Use servers.joinmatrix.org/servers.json

Switching because joinmatrix.org/servers.json is deprecated
This commit is contained in:
Maze 2023-11-30 12:45:35 +01:00
parent bc20e47fb1
commit 565508b217

View File

@ -533,7 +533,7 @@ class Backend:
connector = session.connector, connector = session.connector,
) )
api_list = "https://joinmatrix.org/servers.json" api_list = "https://servers.joinmatrix.org/servers.json"
try: try:
response = await session.get(api_list) response = await session.get(api_list)
except: except:
@ -543,17 +543,19 @@ class Backend:
coros = [] coros = []
for server in (await response.json()): for server in (await response.json())["public_servers"]:
homeserver_url = "https://" + server["domain"] homeserver_url = "https://" + server["client_domain"]
if not server["open"]: # ignore closed servers http_s_re = re.compile("^https?://")
continue # remove https from homepage because it will be re-added later
site_url = (http_s_re.sub("", server["homepage"])
if "homepage" in server else server["client_domain"])
self.models["homeservers"][homeserver_url] = Homeserver( self.models["homeservers"][homeserver_url] = Homeserver(
id = homeserver_url, id = homeserver_url,
name = server["name"], name = server["name"],
site_url = server["domain"], site_url = site_url,
country = server["jurisdiction"], country = server["staff_jur"],
stability = 0, stability = 0,
downtimes_ms = 0, downtimes_ms = 0,
# austin's list doesn't have stability/downtime # austin's list doesn't have stability/downtime