1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

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() trim_cache()
def print_stats(): 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:") #print("Full rundown:")
#import sys #import sys
#for k in cache.keys(): #for k in cache.keys():
@ -77,14 +77,14 @@ def cached_wrapper_individual(inner_func):
else: else:
conn = None conn = None
global hits, misses #global hits, misses
result = {} result = {}
for id in set_arg: for id in set_arg:
if (inner_func,id) in entitycache: if (inner_func,id) in entitycache:
result[id] = entitycache[(inner_func,id)] result[id] = entitycache[(inner_func,id)]
hits += 1 #hits += 1
else: else:
misses += 1 #misses += 1
remaining = inner_func(set(e for e in set_arg if e not in result),dbconn=conn) 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":{ "track":{
"artists":scrobble['artists'], "artists":scrobble['artists'],
"title":scrobble['title'], "title":scrobble['title'],
"album":{
"name":scrobble['album'],
"artists":scrobble['artists']
},
"length":None "length":None
}, },
"duration":scrobble['duration'], "duration":scrobble['duration'],
"origin":"import:" + import_type, "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: if success % 1000 == 0:

View File

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