Basic animated cover support

This commit is contained in:
kramo
2023-04-10 23:24:48 +02:00
parent c1715aa328
commit 62aff0e7cc
6 changed files with 79 additions and 4 deletions

View File

@@ -18,10 +18,14 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from shutil import copyfile
from gi.repository import GdkPixbuf, Gio
def save_cover(parent_widget, game_id, cover_path=None, pixbuf=None):
def save_cover(
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)
@@ -38,3 +42,11 @@ def save_cover(parent_widget, game_id, cover_path=None, pixbuf=None):
["compression"],
["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"],
)
animated_covers_dir = parent_widget.data_dir / "cartridges" / "animated_covers"
(animated_covers_dir / game_id).unlink(missing_ok=True)
if animation_path:
animated_covers_dir.mkdir(parents=True, exist_ok=True)
with animated_covers_dir / game_id as open_file:
copyfile(animation_path, open_file)