Cleanups
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from hashlib import sha256
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
|
||||
@@ -102,7 +102,7 @@ def heroic_importer(win):
|
||||
image_path = (
|
||||
heroic_dir
|
||||
/ "images-cache"
|
||||
/ hashlib.sha256(
|
||||
/ sha256(
|
||||
(f'{game["art_square"]}?h=400&resize=1&w=300').encode()
|
||||
).hexdigest()
|
||||
)
|
||||
@@ -143,7 +143,7 @@ def heroic_importer(win):
|
||||
image_path = (
|
||||
heroic_dir
|
||||
/ "images-cache"
|
||||
/ hashlib.sha256(game["art_square"].encode()).hexdigest()
|
||||
/ sha256(game["art_square"].encode()).hexdigest()
|
||||
)
|
||||
|
||||
values["executable"] = (
|
||||
@@ -193,7 +193,7 @@ def heroic_importer(win):
|
||||
image_path = (
|
||||
heroic_dir
|
||||
/ "images-cache"
|
||||
/ hashlib.sha256(item["art_square"].encode()).hexdigest()
|
||||
/ sha256(item["art_square"].encode()).hexdigest()
|
||||
)
|
||||
|
||||
importer.save_game(values, image_path if image_path.exists() else None)
|
||||
|
||||
@@ -171,7 +171,7 @@ def itch_importer(win):
|
||||
ON
|
||||
caves.game_id = games.id
|
||||
;
|
||||
"""
|
||||
"""
|
||||
|
||||
connection = connect(database_tmp_path)
|
||||
cursor = connection.execute(db_request)
|
||||
|
||||
@@ -96,7 +96,7 @@ def lutris_importer(win):
|
||||
AND configPath IS NOT NULL
|
||||
AND installed IS TRUE
|
||||
;
|
||||
"""
|
||||
"""
|
||||
|
||||
connection = connect(database_tmp_path)
|
||||
cursor = connection.execute(db_request)
|
||||
|
||||
@@ -30,7 +30,6 @@ cartridges_sources = [
|
||||
'importers/itch_importer.py',
|
||||
'utils/importer.py',
|
||||
'utils/steamgriddb.py',
|
||||
'utils/get_games.py',
|
||||
'utils/save_cover.py',
|
||||
'utils/create_dialog.py',
|
||||
'utils/create_details_window.py',
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# get_games.py
|
||||
#
|
||||
# Copyright 2022-2023 kramo
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def get_games(win):
|
||||
games = {}
|
||||
|
||||
if not win.games_dir.exists():
|
||||
return games
|
||||
|
||||
for open_file in win.games_dir.iterdir():
|
||||
data = json.load(open_file.open())
|
||||
games[data["game_id"]] = data
|
||||
|
||||
return games
|
||||
@@ -17,15 +17,15 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from struct import unpack_from
|
||||
|
||||
from gi.repository import Adw, Gdk, GdkPixbuf, Gio, GLib, Gtk
|
||||
|
||||
from .game import Game
|
||||
from .get_games import get_games
|
||||
|
||||
|
||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/window.ui")
|
||||
@@ -107,12 +107,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
||||
)
|
||||
self.image_size = (200 * scale_factor, 300 * scale_factor)
|
||||
|
||||
for game_id, game in get_games(self).items():
|
||||
if game.get("removed"):
|
||||
(self.games_dir / f"{game_id}.json").unlink(missing_ok=True)
|
||||
(self.covers_dir / f"{game_id}.tiff").unlink(missing_ok=True)
|
||||
(self.covers_dir / f"{game_id}.gif").unlink(missing_ok=True)
|
||||
|
||||
self.details_view.set_measure_overlay(self.details_view_box, True)
|
||||
self.details_view.set_clip_overlay(self.details_view_box, False)
|
||||
|
||||
@@ -122,8 +116,20 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
||||
self.library.set_sort_func(self.sort_func)
|
||||
self.hidden_library.set_sort_func(self.sort_func)
|
||||
|
||||
for game in get_games(self).values():
|
||||
Game(self, game).update()
|
||||
games = {}
|
||||
|
||||
if self.games_dir.exists():
|
||||
for open_file in self.games_dir.iterdir():
|
||||
data = json.load(open_file.open())
|
||||
games[data["game_id"]] = data
|
||||
|
||||
for game_id, game in games.items():
|
||||
if game.get("removed"):
|
||||
(self.games_dir / f"{game_id}.json").unlink(missing_ok=True)
|
||||
(self.covers_dir / f"{game_id}.tiff").unlink(missing_ok=True)
|
||||
(self.covers_dir / f"{game_id}.gif").unlink(missing_ok=True)
|
||||
else:
|
||||
Game(self, game).update()
|
||||
|
||||
self.set_library_child()
|
||||
|
||||
@@ -193,8 +199,8 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
||||
self.active_game = game
|
||||
|
||||
def get_time(self, timestamp):
|
||||
date = datetime.datetime.fromtimestamp(timestamp)
|
||||
days_no = (datetime.datetime.today() - date).days
|
||||
date = datetime.fromtimestamp(timestamp)
|
||||
days_no = (datetime.today() - date).days
|
||||
|
||||
if days_no == 0:
|
||||
return _("Today")
|
||||
|
||||
Reference in New Issue
Block a user