re-fetch screenshots only when changed game match

This commit is contained in:
zurdi
2024-04-08 01:23:35 +02:00
parent d32f5cf717
commit dd2f57fc34
2 changed files with 23 additions and 14 deletions

View File

@@ -320,9 +320,11 @@ async def update_rom(
)
if remove_cover:
cleaned_data.update(fs_resource_handler.remove_cover(
rom_name=cleaned_data["name"], platform_fs_slug=platform_fs_slug
))
cleaned_data.update(
fs_resource_handler.remove_cover(
rom_name=cleaned_data["name"], platform_fs_slug=platform_fs_slug
)
)
else:
cleaned_data.update(
fs_resource_handler.get_rom_cover(
@@ -333,13 +335,17 @@ async def update_rom(
)
)
cleaned_data.update(
fs_resource_handler.get_rom_screenshots(
platform_fs_slug=platform_fs_slug,
rom_name=cleaned_data["name"],
url_screenshots=cleaned_data.get("url_screenshots", []),
),
)
if (
cleaned_data["igdb_id"] != db_rom.igdb_id
or cleaned_data["moby_id"] != db_rom.moby_id
):
cleaned_data.update(
fs_resource_handler.get_rom_screenshots(
platform_fs_slug=platform_fs_slug,
rom_name=cleaned_data["name"],
url_screenshots=cleaned_data.get("url_screenshots", []),
),
)
if artwork is not None:
file_ext = artwork.filename.split(".")[-1]

View File

@@ -154,10 +154,13 @@ class FSResourceHandler(FSHandler):
rom_name: str,
platform_fs_slug: str,
):
shutil.rmtree(
os.path.join(RESOURCES_BASE_PATH, platform_fs_slug, rom_name, "cover")
)
return { "path_cover_s": "", "path_cover_l": "" }
try:
shutil.rmtree(
os.path.join(RESOURCES_BASE_PATH, platform_fs_slug, rom_name, "cover")
)
except FileNotFoundError:
log.warning(f"Couldn't remove {rom_name} cover")
return {"path_cover_s": "", "path_cover_l": ""}
@staticmethod
def build_artwork_path(rom_name: str, platform_fs_slug: str, file_ext: str):