mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2025-07-10 19:54:14 +00:00
Some changes:
* Fixes radio * Preparing for separate config in code and config file * Added fetching new instances from network.funkwhale.audio
This commit is contained in:
parent
8245cd433e
commit
52cf8869b4
5 changed files with 89 additions and 13 deletions
69
src/settings.py
Normal file
69
src/settings.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
import json, requests, time
|
||||
from loguru import logger
|
||||
|
||||
defaut_conf = {
|
||||
'instance': 'fw.ponychord.rocks',
|
||||
'public_list_instances': [
|
||||
"open.audio",
|
||||
"audio.securetown.top",
|
||||
"funkwhale.co.uk",
|
||||
"am.pirateradio.social",
|
||||
"audio.liberta.vip",
|
||||
"audio.gafamfree.party",
|
||||
"tanukitunes.com",
|
||||
"funkwhale.juniorjpdj.pl",
|
||||
"tavia.mle.party",
|
||||
"funkwhale.thurk.org",
|
||||
"buzzworkers.com",
|
||||
"soundship.de",
|
||||
"funkwhale.kameha.click",
|
||||
"music.chosto.me",
|
||||
"zik.goe.land",
|
||||
"music.humanoids.be",
|
||||
"music.hempton.us",
|
||||
"mizik.o-k-i.net",
|
||||
"klh.radiolivre.org",
|
||||
"hudba.feildel.fr",
|
||||
"funkwhale.mita.me",
|
||||
"funk.deko.cloud",
|
||||
"audio.graz.social",
|
||||
"funkwhale.desmu.fr",
|
||||
"listen.knsm.cc",
|
||||
"funkwhale.gegeweb.eu",
|
||||
"shitnoise.monster"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@logger.catch
|
||||
def get_new_funkwhale_servers():
|
||||
# Uses official API network.funkwhale.audio for getting new instances
|
||||
public_server_api = 'https://network.funkwhale.audio/dashboards/api/tsdb/query'
|
||||
now = int(time.time())
|
||||
timeback = now - 86400
|
||||
|
||||
request_public_servers = {
|
||||
'from': f"{timeback}",
|
||||
'to': f"{now}",
|
||||
'queries': [
|
||||
{
|
||||
'refId': "A",
|
||||
'intervalMs': 60000,
|
||||
'maxDataPoints': 1174,
|
||||
'datasourceId': 1,
|
||||
'rawSql': "SELECT * FROM (\n SELECT\n DISTINCT on (c.domain) c.domain as \"Name\",\n c.up as \"Is up\",\n coalesce(c.open_registrations, false) as \"Open registrations\",\n coalesce(anonymous_can_listen, false) as \"Anonymous can listen\",\n coalesce(c.usage_users_total, 0) as \"Total users\",\n coalesce(c.usage_users_active_month, 0) as \"Active users (this month)\",\n coalesce(c.software_version_major, 0)::text || '.' || coalesce(c.software_version_minor, 0)::text || '.' || coalesce(c.software_version_patch, 0)::text as \"Version\",\n c.time as \"Last checked\",\n d.first_seen as \"First seen\"\n FROM checks as c\n INNER JOIN domains AS d ON d.name = c.domain\n WHERE d.blocked = false AND c.up = true AND c.time > now() - INTERVAL '7 days'\n AND c.anonymous_can_listen IN ('true')\n AND c.open_registrations IN ('true','false')\n\n ORDER BY c.domain, c.time DESC\n) as t ORDER BY \"Active users (this month)\" DESC",
|
||||
'format': "table"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
r = requests.post(public_server_api, json=request_public_servers)
|
||||
results = r.json()
|
||||
new_instances = []
|
||||
if results:
|
||||
new_instances_list = results['results']['A']['tables'][0]['rows']
|
||||
for i in new_instances_list:
|
||||
if i[0] not in defaut_conf['public_list_instances'] and i[1]:
|
||||
new_instances.append(i[0])
|
||||
return new_instances
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue