From f67f900daef496ab6f0355bd50622b1528587f79 Mon Sep 17 00:00:00 2001 From: Krateng Date: Sat, 16 Jan 2021 20:11:06 +0100 Subject: [PATCH] Fixed image uploading --- maloja/utilities/images.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/maloja/utilities/images.py b/maloja/utilities/images.py index 65f788d..8a099de 100644 --- a/maloja/utilities/images.py +++ b/maloja/utilities/images.py @@ -300,17 +300,15 @@ def set_image(b64,**keys): if os.path.exists(data_dir['images'](folder)): with open(data_dir['images'](folder,filename),"wb") as f: f.write(b64) + break + else: + folder = get_all_possible_filenames(**keys)[0] + os.makedirs(data_dir['images'](folder)) + with open(data_dir['images'](folder,filename),"wb") as f: + f.write(b64) - # set as current picture in rotation - if track: local_track_cache.add((frozenset(keys["artists"]),keys["title"]),os.path.join(folder,filename)) - else: local_artist_cache.add(keys["artist"],os.path.join(folder,filename)) - return - - folder = get_all_possible_filenames(**keys)[0] - os.makedirs(data_dir['images'](folder)) - with open(data_dir['images'](folder,filename),"wb") as f: - f.write(b64) + log("Saved image as " + data_dir['images'](folder,filename),module="debug") # set as current picture in rotation - if track: local_track_cache.add((frozenset(keys["artists"]),keys["title"]),os.path.join(folder,filename)) - else: local_artist_cache.add(keys["artist"],os.path.join(folder,filename)) + if track: local_track_cache.add((frozenset(keys["artists"]),keys["title"]),os.path.join("/images",folder,filename)) + else: local_artist_cache.add(keys["artist"],os.path.join("/images",folder,filename))