Save all covers in a shared directory
This commit is contained in:
@@ -318,10 +318,7 @@ def create_details_window(parent_widget, game_id=None):
|
||||
parent_widget.data_dir / "cartridges" / "covers" / f"{game_id}.tiff"
|
||||
).unlink(missing_ok=True)
|
||||
(
|
||||
parent_widget.data_dir
|
||||
/ "cartridges"
|
||||
/ "animated_covers"
|
||||
/ f"{game_id}.gif"
|
||||
parent_widget.data_dir / "cartridges" / "covers" / f"{game_id}.gif"
|
||||
).unlink(missing_ok=True)
|
||||
|
||||
elif not (
|
||||
|
||||
@@ -43,17 +43,21 @@ def resize_animation(cover_path):
|
||||
|
||||
|
||||
def save_cover(
|
||||
parent_widget, game_id, cover_path=None, pixbuf=None, animation_path=None
|
||||
parent_widget,
|
||||
game_id,
|
||||
cover_path=None,
|
||||
pixbuf=None,
|
||||
animation_path=None,
|
||||
):
|
||||
covers_dir = parent_widget.data_dir / "cartridges" / "covers"
|
||||
|
||||
covers_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if animation_path:
|
||||
pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(
|
||||
str(animation_path)
|
||||
).get_static_image()
|
||||
elif not pixbuf:
|
||||
(covers_dir / f"{game_id}.tiff").unlink(missing_ok=True)
|
||||
copyfile(animation_path, covers_dir / f"{game_id}.gif")
|
||||
return
|
||||
|
||||
if not pixbuf:
|
||||
try:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
str(cover_path), *parent_widget.image_size, False
|
||||
@@ -68,9 +72,3 @@ def save_cover(
|
||||
["compression"],
|
||||
["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"],
|
||||
)
|
||||
|
||||
if animation_path:
|
||||
animation_dir = parent_widget.data_dir / "cartridges" / "animated_covers"
|
||||
animation_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
copyfile(animation_path, animation_dir / f"{game_id}.gif")
|
||||
|
||||
@@ -29,12 +29,20 @@ class SGDBSave:
|
||||
def update_cover(self, task, game):
|
||||
if self.parent_widget.schema.get_boolean("sgdb") and (
|
||||
self.parent_widget.schema.get_boolean("sgdb-prefer")
|
||||
or not (
|
||||
self.parent_widget.data_dir
|
||||
/ "cartridges"
|
||||
/ "covers"
|
||||
/ f"{game[0]}.tiff"
|
||||
).is_file()
|
||||
or not any(
|
||||
(
|
||||
self.parent_widget.data_dir
|
||||
/ "cartridges"
|
||||
/ "covers"
|
||||
/ f"{game[0]}.tiff"
|
||||
).is_file(),
|
||||
(
|
||||
self.parent_widget.data_dir
|
||||
/ "cartridges"
|
||||
/ "covers"
|
||||
/ f"{game[0]}.gif"
|
||||
).is_file(),
|
||||
)
|
||||
):
|
||||
if not self.importer:
|
||||
self.parent_widget.loading = game[0]
|
||||
|
||||
Reference in New Issue
Block a user