mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Bugfixes
This commit is contained in:
parent
194bc6c742
commit
51c41b5cd8
12
database.py
12
database.py
@ -16,6 +16,7 @@ import sys
|
|||||||
import unicodedata
|
import unicodedata
|
||||||
import json
|
import json
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from threading import Lock
|
||||||
# url handling
|
# url handling
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
import urllib
|
import urllib
|
||||||
@ -25,11 +26,15 @@ import urllib
|
|||||||
|
|
||||||
dbserver = Bottle()
|
dbserver = Bottle()
|
||||||
|
|
||||||
|
dblock = Lock() #global database lock
|
||||||
|
|
||||||
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
|
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
|
||||||
ARTISTS = [] # Format: artist
|
ARTISTS = [] # Format: artist
|
||||||
TRACKS = [] # Format: namedtuple(artists=frozenset(artist_ref,...),title=title)
|
TRACKS = [] # Format: namedtuple(artists=frozenset(artist_ref,...),title=title)
|
||||||
|
|
||||||
|
ARTIST_SET = set()
|
||||||
|
TRACK_SET = set()
|
||||||
|
|
||||||
Track = namedtuple("Track",["artists","title"])
|
Track = namedtuple("Track",["artists","title"])
|
||||||
Scrobble = namedtuple("Scrobble",["track","timestamp","saved"])
|
Scrobble = namedtuple("Scrobble",["track","timestamp","saved"])
|
||||||
|
|
||||||
@ -71,8 +76,8 @@ def checkAPIkey(k):
|
|||||||
####
|
####
|
||||||
|
|
||||||
def get_scrobble_dict(o):
|
def get_scrobble_dict(o):
|
||||||
track = get_track_dict(TRACKS[o.track)
|
track = get_track_dict(TRACKS[o.track])
|
||||||
return {"artists":track["artists"],"title":track["title"],"time":o.time}
|
return {"artists":track["artists"],"title":track["title"],"time":o.timestamp}
|
||||||
|
|
||||||
def get_artist_dict(o):
|
def get_artist_dict(o):
|
||||||
return o
|
return o
|
||||||
@ -90,6 +95,7 @@ def get_track_dict(o):
|
|||||||
|
|
||||||
|
|
||||||
def createScrobble(artists,title,time,volatile=False):
|
def createScrobble(artists,title,time,volatile=False):
|
||||||
|
dblock.acquire()
|
||||||
while (time in SCROBBLESDICT):
|
while (time in SCROBBLESDICT):
|
||||||
time += 1
|
time += 1
|
||||||
i = getTrackID(artists,title)
|
i = getTrackID(artists,title)
|
||||||
@ -101,8 +107,10 @@ def createScrobble(artists,title,time,volatile=False):
|
|||||||
STAMPS.insert(index,time) #should be same index as scrobblelist
|
STAMPS.insert(index,time) #should be same index as scrobblelist
|
||||||
register_scrobbletime(time)
|
register_scrobbletime(time)
|
||||||
invalidate_caches()
|
invalidate_caches()
|
||||||
|
dblock.release()
|
||||||
|
|
||||||
|
|
||||||
|
# this will never be called from different threads, so no lock
|
||||||
def readScrobble(artists,title,time):
|
def readScrobble(artists,title,time):
|
||||||
while (time in SCROBBLESDICT):
|
while (time in SCROBBLESDICT):
|
||||||
time += 1
|
time += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user