Small fixes

This commit is contained in:
krateng 2022-03-27 19:52:51 +02:00
parent e22ef4d268
commit be4ed055ff
3 changed files with 10 additions and 9 deletions

View File

@ -32,7 +32,7 @@ def maintenance():
trim_cache()
def print_stats():
log(f"Cache Size: {len(cache)+len(entitycache)}, System RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
log(f"Cache Size: {len(cache)} [{len(entitycache)} E], System RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
#print("Full rundown:")
#import sys
#for k in cache.keys():
@ -77,14 +77,14 @@ def cached_wrapper_individual(inner_func):
else:
conn = None
global hits, misses
#global hits, misses
result = {}
for id in set_arg:
if (inner_func,id) in entitycache:
result[id] = entitycache[(inner_func,id)]
hits += 1
#hits += 1
else:
misses += 1
#misses += 1
remaining = inner_func(set(e for e in set_arg if e not in result),dbconn=conn)

View File

@ -60,15 +60,15 @@ def import_scrobbles(fromfile):
"track":{
"artists":scrobble['artists'],
"title":scrobble['title'],
"album":{
"name":scrobble['album'],
"artists":scrobble['artists']
},
"length":None
},
"duration":scrobble['duration'],
"origin":"import:" + import_type,
"extra":{}
"extra":{
"album":scrobble['album']
# saving this in the scrobble instead of the track because for now it's not meant
# to be authorative information, just payload of the scrobble
}
})
if success % 1000 == 0:

View File

@ -87,6 +87,7 @@ def remove_image_from_cache(id,table):
def dl_image(url):
if not malojaconfig["PROXY_IMAGES"]: return None
if url is None: return None
if url.startswith("/"): return None #local image
try:
r = requests.get(url)
mime = r.headers.get('content-type') or 'image/jpg'