Moved schemas to shared module (#94)

This commit is contained in:
Geoffrey Coulaud
2023-05-21 16:34:22 +02:00
committed by GitHub
parent d6cda0c562
commit ab21e8b38b
12 changed files with 58 additions and 36 deletions

View File

@@ -24,6 +24,8 @@ from shutil import copyfile
from gi.repository import Gio
from PIL import Image, ImageSequence
from . import shared
def resize_cover(win, cover_path=None, pixbuf=None):
if not cover_path and not pixbuf:
@@ -56,7 +58,7 @@ def resize_cover(win, cover_path=None, pixbuf=None):
image.resize(win.image_size).save(
tmp_path,
compression="tiff_adobe_deflate"
if win.schema.get_boolean("high-quality-images")
if shared.schema.get_boolean("high-quality-images")
else "webp",
)

View File

@@ -3,6 +3,7 @@ from pathlib import Path
import requests
from gi.repository import Gio
from . import shared
from .create_dialog import create_dialog
from .save_cover import save_cover, resize_cover
@@ -31,9 +32,9 @@ class SGDBSave:
if (
not (
self.win.schema.get_boolean("sgdb")
shared.schema.get_boolean("sgdb")
and (
(self.win.schema.get_boolean("sgdb-prefer"))
(shared.schema.get_boolean("sgdb-prefer"))
or not (
(self.win.covers_dir / f"{game.game_id}.gif").is_file()
or (self.win.covers_dir / f"{game.game_id}.tiff").is_file()
@@ -46,7 +47,7 @@ class SGDBSave:
return
url = "https://www.steamgriddb.com/api/v2/"
headers = {"Authorization": f'Bearer {self.win.schema.get_string("sgdb-key")}'}
headers = {"Authorization": f'Bearer {shared.schema.get_string("sgdb-key")}'}
try:
search_result = requests.get(
@@ -68,7 +69,7 @@ class SGDBSave:
response = None
try:
if self.win.schema.get_boolean("sgdb-animated"):
if shared.schema.get_boolean("sgdb-animated"):
try:
grid = requests.get(
f'{url}grids/game/{search_result.json()["data"][0]["id"]}?dimensions=600x900&types=animated',