Compare commits

...

7 Commits
v1.3 ... v1.3.2

Author SHA1 Message Date
kramo
9986e35365 v1.3.2 2023-04-06 14:24:43 +02:00
kramo
c8bc101c96 Fix SteamGridDB query 2023-04-06 14:21:40 +02:00
kramo
06026757d6 Fix SteamGridDB if no internet connection 2023-04-06 14:15:23 +02:00
kramo
d2064ecaf4 Use the requests library consistently 2023-04-06 13:55:49 +02:00
kramo
ed3b8d7019 Fix Steam import property case bug 2023-04-06 12:21:02 +02:00
kramo
1279514c30 v1.3.1 2023-04-06 11:38:54 +02:00
kramo
b580e55c02 Fix inconsistent faulty Steam import 2023-04-06 11:32:57 +02:00
9 changed files with 105 additions and 80 deletions

View File

@@ -15,14 +15,13 @@ jobs:
with: with:
msystem: UCRT64 msystem: UCRT64
update: true update: true
install: mingw-w64-ucrt-x86_64-gtk4 mingw-w64-ucrt-x86_64-libadwaita mingw-w64-ucrt-x86_64-python-gobject mingw-w64-ucrt-x86_64-python-yaml mingw-w64-ucrt-x86_64-python-pip mingw-w64-ucrt-x86_64-desktop-file-utils mingw-w64-ucrt-x86_64-ca-certificates mingw-w64-ucrt-x86_64-meson git install: mingw-w64-ucrt-x86_64-gtk4 mingw-w64-ucrt-x86_64-libadwaita mingw-w64-ucrt-x86_64-python-gobject mingw-w64-ucrt-x86_64-python-yaml mingw-w64-ucrt-x86_64-python-requests mingw-w64-ucrt-x86_64-desktop-file-utils mingw-w64-ucrt-x86_64-ca-certificates mingw-w64-ucrt-x86_64-meson git
- name: Compile - name: Compile
shell: msys2 {0} shell: msys2 {0}
run: | run: |
pip install python-steamgriddb
meson setup _build meson setup _build
ninja -C _build install ninja -C _build install
pacman --noconfirm -Rs mingw-w64-ucrt-x86_64-python-pip mingw-w64-ucrt-x86_64-desktop-file-utils mingw-w64-ucrt-x86_64-meson git pacman --noconfirm -Rs mingw-w64-ucrt-x86_64-desktop-file-utils mingw-w64-ucrt-x86_64-meson git
find /ucrt64/share/locale/ -type f ! -name "*cartridges.mo" -delete find /ucrt64/share/locale/ -type f ! -name "*cartridges.mo" -delete
- name: "Inno Setup" - name: "Inno Setup"
run: iscc ".\.windows\Cartridges.iss" run: iscc ".\.windows\Cartridges.iss"

View File

@@ -1,5 +1,5 @@
#define MyAppName "Cartridges" #define MyAppName "Cartridges"
#define MyAppVersion "1.3" #define MyAppVersion "1.3.2"
#define MyAppPublisher "kramo" #define MyAppPublisher "kramo"
#define MyAppURL "https://github.com/kra-mo/cartridges" #define MyAppURL "https://github.com/kra-mo/cartridges"
#define MyAppExeName "pythonw.exe" #define MyAppExeName "pythonw.exe"

View File

@@ -36,6 +36,13 @@
</screenshots> </screenshots>
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="1.3.2" date="2023-04-06">
<description translatable="no">
<ul>
<li>Better SteamGridDB filtering</li>
</ul>
</description>
</release>
<release version="1.3" date="2023-04-06"> <release version="1.3" date="2023-04-06">
<description translatable="no"> <description translatable="no">
<ul> <ul>

View File

@@ -36,55 +36,57 @@
], ],
"modules" : [ "modules" : [
{ {
"name": "python3-pyyaml", "name": "python3-modules",
"buildsystem": "simple", "buildsystem": "simple",
"build-commands": [ "build-commands": [],
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"pyyaml\" --no-build-isolation" "modules": [
],
"sources": [
{ {
"type": "file", "name": "python3-pyyaml",
"url": "https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz", "buildsystem": "simple",
"sha256": "68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2" "build-commands": [
} "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"pyyaml\" --no-build-isolation"
] ],
}, "sources": [
{ {
"name": "python3-python-steamgriddb", "type": "file",
"buildsystem": "simple", "url": "https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz",
"build-commands": [ "sha256": "68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"python-steamgriddb\" --no-build-isolation" }
], ]
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/71/4c/3db2b8021bd6f2f0ceb0e088d6b2d49147671f25832fb17970e9b583d742/certifi-2022.12.7-py3-none-any.whl",
"sha256": "4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"
}, },
{ {
"type": "file", "name": "python3-requests",
"url": "https://files.pythonhosted.org/packages/ff/d7/8d757f8bd45be079d76309248845a04f09619a7b17d6dfc8c9ff6433cac2/charset-normalizer-3.1.0.tar.gz", "buildsystem": "simple",
"sha256": "34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5" "build-commands": [
}, "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"requests\" --no-build-isolation"
{ ],
"type": "file", "sources": [
"url": "https://files.pythonhosted.org/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl", {
"sha256": "90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" "type": "file",
}, "url": "https://files.pythonhosted.org/packages/71/4c/3db2b8021bd6f2f0ceb0e088d6b2d49147671f25832fb17970e9b583d742/certifi-2022.12.7-py3-none-any.whl",
{ "sha256": "4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"
"type": "file", },
"url": "https://files.pythonhosted.org/packages/d6/90/a84d927799ca177d4f7a111f99fee0a3f19da63e42c3b325c9c1bfe3bba0/python-steamgriddb-1.0.5.tar.gz", {
"sha256": "036db7bb09865da73b40b68cf04fb9675cd18b4908275092d91f37bf16245069" "type": "file",
}, "url": "https://files.pythonhosted.org/packages/ff/d7/8d757f8bd45be079d76309248845a04f09619a7b17d6dfc8c9ff6433cac2/charset-normalizer-3.1.0.tar.gz",
{ "sha256": "34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5"
"type": "file", },
"url": "https://files.pythonhosted.org/packages/d2/f4/274d1dbe96b41cf4e0efb70cbced278ffd61b5c7bb70338b62af94ccb25b/requests-2.28.2-py3-none-any.whl", {
"sha256": "64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa" "type": "file",
}, "url": "https://files.pythonhosted.org/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl",
{ "sha256": "90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
"type": "file", },
"url": "https://files.pythonhosted.org/packages/7b/f5/890a0baca17a61c1f92f72b81d3c31523c99bec609e60c292ea55b387ae8/urllib3-1.26.15-py2.py3-none-any.whl", {
"sha256": "aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42" "type": "file",
"url": "https://files.pythonhosted.org/packages/d2/f4/274d1dbe96b41cf4e0efb70cbced278ffd61b5c7bb70338b62af94ccb25b/requests-2.28.2-py3-none-any.whl",
"sha256": "64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/7b/f5/890a0baca17a61c1f92f72b81d3c31523c99bec609e60c292ea55b387ae8/urllib3-1.26.15-py2.py3-none-any.whl",
"sha256": "aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"
}
]
} }
] ]
}, },

View File

@@ -1,5 +1,5 @@
project('cartridges', project('cartridges',
version: '1.3', version: '1.3.2',
meson_version: '>= 0.59.0', meson_version: '>= 0.59.0',
default_options: [ 'warning_level=2', 'werror=false', ], default_options: [ 'warning_level=2', 'werror=false', ],
) )

View File

@@ -113,7 +113,7 @@ class CartridgesApplication(Adw.Application):
application_name=_("Cartridges"), application_name=_("Cartridges"),
application_icon="hu.kramo.Cartridges", application_icon="hu.kramo.Cartridges",
developer_name="kramo", developer_name="kramo",
version="1.3", version="1.3.2",
developers=[ developers=[
"kramo https://kramo.hu", "kramo https://kramo.hu",
"Paweł Lidwin https://github.com/imLinguin", "Paweł Lidwin https://github.com/imLinguin",

View File

@@ -18,12 +18,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import os import os
import urllib.request
from pathlib import Path from pathlib import Path
from shutil import copyfile from shutil import copyfile
from sqlite3 import connect from sqlite3 import connect
from time import time from time import time
import requests
from gi.repository import GdkPixbuf, Gio from gi.repository import GdkPixbuf, Gio
@@ -53,9 +53,10 @@ def get_game(task, current_time, parent_widget, row):
if row[3] or row[2]: if row[3] or row[2]:
tmp_file = Gio.File.new_tmp(None)[0] tmp_file = Gio.File.new_tmp(None)[0]
try: try:
with urllib.request.urlopen(row[3] or row[2], timeout=5) as open_file: with requests.get(row[3] or row[2], timeout=5) as cover:
Path(tmp_file.get_path()).write_bytes(open_file.read()) cover.raise_for_status()
except urllib.error.URLError: Path(tmp_file.get_path()).write_bytes(cover.content)
except requests.exceptions.RequestException:
task.return_value((values, None)) task.return_value((values, None))
return return

View File

@@ -17,18 +17,17 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import json
import os import os
import re import re
import urllib.request
from pathlib import Path from pathlib import Path
from time import time from time import time
import requests
from gi.repository import Gio from gi.repository import Gio
def update_values_from_data(content, values): def update_values_from_data(content, values):
basic_data = json.loads(content)[values["appid"]] basic_data = content[values["appid"]]
if not basic_data["success"]: if not basic_data["success"]:
values["blacklisted"] = True values["blacklisted"] = True
else: else:
@@ -41,15 +40,17 @@ def update_values_from_data(content, values):
return values return values
def get_game( def get_game(task, datatypes, current_time, parent_widget, appmanifest, steam_dir):
task, datatypes, current_time, parent_widget, appmanifest, steam_dir, importer
):
values = {} values = {}
data = appmanifest.read_text("utf-8") data = appmanifest.read_text("utf-8")
for datatype in datatypes: for datatype in datatypes:
value = re.findall(f'"{datatype}"\t\t"(.*)"\n', data) value = re.findall(f'"{datatype}"\t\t"(.*)"\n', data, re.IGNORECASE)
values[datatype] = value[0] try:
values[datatype] = value[0]
except IndexError:
task.return_value((None, None))
return
values["game_id"] = f'steam_{values["appid"]}' values["game_id"] = f'steam_{values["appid"]}'
@@ -78,12 +79,13 @@ def get_game(
) )
try: try:
with urllib.request.urlopen( with requests.get(
f'https://store.steampowered.com/api/appdetails?appids={values["appid"]}', f'https://store.steampowered.com/api/appdetails?appids={values["appid"]}',
timeout=5, timeout=5,
) as open_file: ) as open_file:
content = open_file.read().decode("utf-8") open_file.raise_for_status()
except urllib.error.URLError: content = open_file.json()
except requests.exceptions.RequestException:
task.return_value((values, image_path if image_path.exists() else None)) task.return_value((values, image_path if image_path.exists() else None))
return return
@@ -105,7 +107,6 @@ def get_games_async(parent_widget, appmanifests, steam_dir, importer):
parent_widget, parent_widget,
appmanifest, appmanifest,
steam_dir, steam_dir,
importer,
) )
return wrapper return wrapper

View File

@@ -2,7 +2,6 @@ from pathlib import Path
import requests import requests
from gi.repository import Gio from gi.repository import Gio
from steamgrid import SteamGridDB, http
from .create_dialog import create_dialog from .create_dialog import create_dialog
from .save_cover import save_cover from .save_cover import save_cover
@@ -11,7 +10,6 @@ from .save_cover import save_cover
class SGDBSave: class SGDBSave:
def __init__(self, parent_widget, games, importer=None): def __init__(self, parent_widget, games, importer=None):
self.parent_widget = parent_widget self.parent_widget = parent_widget
self.sgdb = SteamGridDB(self.parent_widget.schema.get_string("sgdb-key"))
self.importer = importer self.importer = importer
self.exception = None self.exception = None
@@ -41,29 +39,46 @@ class SGDBSave:
if not self.importer: if not self.importer:
self.parent_widget.loading = game[0] self.parent_widget.loading = game[0]
url = "https://www.steamgriddb.com/api/v2/"
headers = {
"Authorization": f'Bearer {self.parent_widget.schema.get_string("sgdb-key")}'
}
try: try:
search_result = self.sgdb.search_game(game[1]) search_result = requests.get(
f"{url}search/autocomplete/{game[1]}",
headers=headers,
timeout=5,
)
if search_result.status_code != 200:
self.exception = str(
search_result.json()["errors"][0]
if "errors" in tuple(search_result.json())
else search_result.status_code
)
search_result.raise_for_status()
except requests.exceptions.RequestException: except requests.exceptions.RequestException:
task.return_value(game[0]) task.return_value(game[0])
return return
except http.HTTPException as exception:
self.exception = str(exception)
task.return_value(game[0])
return
try: try:
grid = self.sgdb.get_grids_by_gameid( grid = requests.get(
[search_result[0].id], is_nsfw=False f'{url}grids/game/{search_result.json()["data"][0]["id"]}?dimensions=600x900',
)[0] headers=headers,
except (TypeError, IndexError): timeout=5,
)
except (requests.exceptions.RequestException, IndexError):
task.return_value(game[0]) task.return_value(game[0])
return return
tmp_file = Gio.File.new_tmp(None)[0] tmp_file = Gio.File.new_tmp(None)[0]
try: try:
response = requests.get(str(grid), timeout=5) response = requests.get(
except requests.exceptions.RequestException: grid.json()["data"][0]["url"],
timeout=5,
)
except (requests.exceptions.RequestException, IndexError):
task.return_value(game[0]) task.return_value(game[0])
return return