Reload Uninstalled image when installed image reloaded
This commit is contained in:
parent
c3ee315e02
commit
9b1c068a07
1 changed files with 47 additions and 40 deletions
|
@ -61,6 +61,7 @@ def download_image(game, force=False):
|
||||||
else:
|
else:
|
||||||
json_data = json.load(open(f"{image_dir}/{game.app_name}/image.json", "r"))
|
json_data = json.load(open(f"{image_dir}/{game.app_name}/image.json", "r"))
|
||||||
# Download
|
# Download
|
||||||
|
download = False
|
||||||
for image in game.metadata["keyImages"]:
|
for image in game.metadata["keyImages"]:
|
||||||
if image["type"] == "DieselGameBoxTall" or image["type"] == "DieselGameBoxLogo" or image["type"] == "Thumbnail":
|
if image["type"] == "DieselGameBoxTall" or image["type"] == "DieselGameBoxLogo" or image["type"] == "Thumbnail":
|
||||||
if image["type"] not in json_data.keys():
|
if image["type"] not in json_data.keys():
|
||||||
|
@ -79,11 +80,16 @@ def download_image(game, force=False):
|
||||||
img = Image.open(f"{image_dir}/{game.app_name}/{image['type']}.png")
|
img = Image.open(f"{image_dir}/{game.app_name}/{image['type']}.png")
|
||||||
img = img.resize((200, int(200 * 4 / 3)))
|
img = img.resize((200, int(200 * 4 / 3)))
|
||||||
img.save(f"{image_dir}/{game.app_name}/{image['type']}.png")
|
img.save(f"{image_dir}/{game.app_name}/{image['type']}.png")
|
||||||
|
download = True
|
||||||
except UnidentifiedImageError as e:
|
except UnidentifiedImageError as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
|
||||||
# scale and grey
|
# scale and grey
|
||||||
if not os.path.exists(os.path.join(image_dir, game.app_name + '/UninstalledArt.png')):
|
uninstalled_image = os.path.join(image_dir, game.app_name + '/UninstalledArt.png')
|
||||||
|
if download and os.path.exists(uninstalled_image):
|
||||||
|
os.remove(uninstalled_image)
|
||||||
|
elif os.path.exists(uninstalled_image):
|
||||||
|
return
|
||||||
|
|
||||||
if os.path.exists(os.path.join(image_dir, f"{game.app_name}/DieselGameBoxTall.png")):
|
if os.path.exists(os.path.join(image_dir, f"{game.app_name}/DieselGameBoxTall.png")):
|
||||||
# finalArt = Image.open(f'{image_dir}/' + game.app_name + '/DieselGameBoxTall.png')
|
# finalArt = Image.open(f'{image_dir}/' + game.app_name + '/DieselGameBoxTall.png')
|
||||||
|
@ -100,6 +106,7 @@ def download_image(game, force=False):
|
||||||
uninstalledArt = bg.convert('L')
|
uninstalledArt = bg.convert('L')
|
||||||
uninstalledArt = uninstalledArt.resize((200, int(200 * 4 / 3)))
|
uninstalledArt = uninstalledArt.resize((200, int(200 * 4 / 3)))
|
||||||
uninstalledArt.save(f'{image_dir}/{game.app_name}/UninstalledArt.png')
|
uninstalledArt.save(f'{image_dir}/{game.app_name}/UninstalledArt.png')
|
||||||
|
|
||||||
elif os.path.isfile(f"{image_dir}/{game.app_name}/DieselGameBoxLogo.png"):
|
elif os.path.isfile(f"{image_dir}/{game.app_name}/DieselGameBoxLogo.png"):
|
||||||
bg: Image.Image = Image.open(f"{image_dir}/{game.app_name}/DieselGameBoxLogo.png")
|
bg: Image.Image = Image.open(f"{image_dir}/{game.app_name}/DieselGameBoxLogo.png")
|
||||||
bg = bg.resize((int(bg.size[1] * 3 / 4), bg.size[1]))
|
bg = bg.resize((int(bg.size[1] * 3 / 4), bg.size[1]))
|
||||||
|
|
Loading…
Reference in a new issue