forked from NinjaCheetah/NUSGet
Title trees are now model-based rather than item based. Coming with this is proper item metadata, so the data and UI are finally disconnected, making future development much easier. There are also some minor visual improvements as a result of using a TreeView instead of a TreeWidget. vWii System Menus now have public versions defined in the database. Public version display code has also been entirely rewritten, as the version displayed in the interface and the version used by the code are no longer the same.
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
# "modules/core.py", licensed under the MIT license
|
|
# Copyright 2024 NinjaCheetah
|
|
|
|
import requests
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class TitleData:
|
|
# Class to store all data for a Title.
|
|
tid: str
|
|
name: str
|
|
archive_name: str
|
|
version: str
|
|
ticket: bool
|
|
region: str
|
|
category: str
|
|
danger: str
|
|
|
|
|
|
def check_nusget_updates(app, current_version: str, progress_callback=None) -> str | None:
|
|
# Simple function to make a request to the GitHub API and then check if the latest available version is newer.
|
|
gh_api_request = requests.get(url="https://api.github.com/repos/NinjaCheetah/NUSGet/releases/latest", stream=True)
|
|
if gh_api_request.status_code != 200:
|
|
progress_callback.emit(app.translate("MainWindow", "\n\nCould not check for updates."))
|
|
else:
|
|
api_response = gh_api_request.json()
|
|
new_version: str = api_response["tag_name"].replace('v', '')
|
|
new_version_split = new_version.split('.')
|
|
current_version_split = current_version.split('.')
|
|
for place in range(len(new_version_split)):
|
|
if new_version_split[place] > current_version_split[place]:
|
|
progress_callback.emit(app.translate("MainWindow", "\n\nThere's a newer version of NUSGet available!"))
|
|
return new_version
|
|
progress_callback.emit(app.translate("MainWindow", "\n\nYou're running the latest release of NUSGet."))
|
|
return None
|