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",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,0,4
|
version = 2,0,5
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,3 +57,4 @@ NAME = None
|
|||||||
|
|
||||||
EXPERIMENTAL_FEATURES = no
|
EXPERIMENTAL_FEATURES = no
|
||||||
USE_PYHP = no
|
USE_PYHP = no
|
||||||
|
FEDERATION = yes
|
||||||
|
@ -27,6 +27,7 @@ import sys
|
|||||||
import unicodedata
|
import unicodedata
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
import yaml
|
||||||
# url handling
|
# url handling
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
import urllib
|
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
|
# rulestate that the entire current database was built with, or False if the database was built from inconsistent scrobble files
|
||||||
db_rulestate = False
|
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
|
### symmetric keys are fine for now since we hopefully use HTTPS
|
||||||
@ -264,6 +277,10 @@ def get_scrobbles(**keys):
|
|||||||
# info for comparison
|
# info for comparison
|
||||||
@dbserver.get("info")
|
@dbserver.get("info")
|
||||||
def info_external(**keys):
|
def info_external(**keys):
|
||||||
|
|
||||||
|
response.set_header("Access-Control-Allow-Origin","*")
|
||||||
|
response.set_header("Content-Type","application/json")
|
||||||
|
|
||||||
result = info()
|
result = info()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -275,7 +292,9 @@ def info():
|
|||||||
"name":settings.get_settings("NAME"),
|
"name":settings.get_settings("NAME"),
|
||||||
"artists":{
|
"artists":{
|
||||||
chartentry["artist"]:round(chartentry["scrobbles"] * 100 / totalscrobbles,3)
|
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()
|
owninfo = database.info()
|
||||||
|
|
||||||
|
database.add_known_server(compareto)
|
||||||
|
|
||||||
artists = {}
|
artists = {}
|
||||||
|
|
||||||
for a in owninfo["artists"]:
|
for a in owninfo["artists"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user