Added setting not to use local images

This commit is contained in:
Krateng 2019-04-07 13:22:33 +02:00
parent c3515080ae
commit 549fc09e7b
2 changed files with 23 additions and 24 deletions

View File

@ -14,4 +14,5 @@ CACHE_EXPIRE_POSITIVE = 300 # after how many days positive results should be ref
[Local Images]
USE_LOCAL_IMAGES = true
LOCAL_IMAGE_ROTATE = 3600 # when multiple images are present locally, how many seconds we wait between rotation

View File

@ -286,15 +286,17 @@ def getTrackImage(artists,title,fast=False):
# if filename == "": filename = str(hash(obj))
# filepath = "images/tracks/" + filename
try:
return local_track_cache.get((frozenset(artists),title))
except:
images = local_files(artists=artists,title=title)
if len(images) != 0:
#return random.choice(images)
res = random.choice(images)
local_track_cache.add((frozenset(artists),title),res)
return urllib.parse.quote(res)
if settings.get_settings("USE_LOCAL_IMAGES"):
try:
return local_track_cache.get((frozenset(artists),title))
except:
images = local_files(artists=artists,title=title)
if len(images) != 0:
#return random.choice(images)
res = random.choice(images)
local_track_cache.add((frozenset(artists),title),res)
return urllib.parse.quote(res)
# check if custom image exists
@ -359,15 +361,17 @@ def getArtistImage(artist,fast=False):
# filepath = "images/artists/" + filename
# #filepath_cache = "info/artists_cache/" + filename
try:
return local_artist_cache.get(artist)
except:
images = local_files(artist=artist)
if len(images) != 0:
#return random.choice(images)
res = random.choice(images)
local_artist_cache.add(artist,res)
return urllib.parse.quote(res)
if settings.get_settings("USE_LOCAL_IMAGES"):
try:
return local_artist_cache.get(artist)
except:
images = local_files(artist=artist)
if len(images) != 0:
#return random.choice(images)
res = random.choice(images)
local_artist_cache.add(artist,res)
return urllib.parse.quote(res)
# check if custom image exists
@ -511,9 +515,3 @@ def update_medals():
elif t["rank"] == 2: MEDALS_TRACKS.setdefault(track,{}).setdefault("silver",[]).append(year)
elif t["rank"] == 3: MEDALS_TRACKS.setdefault(track,{}).setdefault("bronze",[]).append(year)
else: break
@daily
def scheduletest():
log("New day!",module="debug")