mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Some preparations
This commit is contained in:
parent
1316026999
commit
d11a1ea9c2
@ -7,7 +7,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,0,4
|
||||
version = 2,0,5
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
|
||||
|
||||
|
@ -57,3 +57,4 @@ NAME = None
|
||||
|
||||
EXPERIMENTAL_FEATURES = no
|
||||
USE_PYHP = no
|
||||
FEDERATION = yes
|
||||
|
@ -27,6 +27,7 @@ import sys
|
||||
import unicodedata
|
||||
from collections import namedtuple
|
||||
from threading import Lock
|
||||
import yaml
|
||||
# url handling
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import urllib
|
||||
@ -66,6 +67,18 @@ lastsync = 0
|
||||
# rulestate that the entire current database was built with, or False if the database was built from inconsistent scrobble files
|
||||
db_rulestate = False
|
||||
|
||||
try:
|
||||
with open("known_servers.yml","r") as f:
|
||||
KNOWN_SERVERS = set(yaml.safe_load(f))
|
||||
except:
|
||||
KNOWN_SERVERS = set()
|
||||
|
||||
|
||||
def add_known_server(url):
|
||||
KNOWN_SERVERS.add(url)
|
||||
with open("known_servers.yml","w") as f:
|
||||
f.write(yaml.dump(list(KNOWN_SERVERS)))
|
||||
|
||||
|
||||
|
||||
### symmetric keys are fine for now since we hopefully use HTTPS
|
||||
@ -264,6 +277,10 @@ def get_scrobbles(**keys):
|
||||
# info for comparison
|
||||
@dbserver.get("info")
|
||||
def info_external(**keys):
|
||||
|
||||
response.set_header("Access-Control-Allow-Origin","*")
|
||||
response.set_header("Content-Type","application/json")
|
||||
|
||||
result = info()
|
||||
return result
|
||||
|
||||
@ -275,7 +292,9 @@ def info():
|
||||
"name":settings.get_settings("NAME"),
|
||||
"artists":{
|
||||
chartentry["artist"]:round(chartentry["scrobbles"] * 100 / totalscrobbles,3)
|
||||
for chartentry in get_charts_artists() if chartentry["scrobbles"]/totalscrobbles >= 0}
|
||||
for chartentry in get_charts_artists() if chartentry["scrobbles"]/totalscrobbles >= 0
|
||||
},
|
||||
"known_servers":list(KNOWN_SERVERS)
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,8 @@ def instructions(keys):
|
||||
|
||||
owninfo = database.info()
|
||||
|
||||
database.add_known_server(compareto)
|
||||
|
||||
artists = {}
|
||||
|
||||
for a in owninfo["artists"]:
|
||||
|
Loading…
Reference in New Issue
Block a user