mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
download latest web client as fallback
This commit is contained in:
+31
-14
@@ -98,21 +98,11 @@ class AssetHandler:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download_client_from_github():
|
def process_release(release: dict, path: Path):
|
||||||
"""
|
"""
|
||||||
Downloads the latest supported client from Github
|
Processes a release from the GitHub API.
|
||||||
and places it in the swingmusic client folder.
|
|
||||||
"""
|
"""
|
||||||
log.error("Default client not found. Downloading from GitHub ...")
|
|
||||||
path = Paths().client_path
|
|
||||||
|
|
||||||
try:
|
|
||||||
# INFO: downlaod the current version of the client from GitHub
|
|
||||||
releases = requests.get(AssetHandler.RELEASES_URL).json()
|
|
||||||
|
|
||||||
# INFO: find the release for the current version
|
|
||||||
for release in releases:
|
|
||||||
if release["tag_name"] == f"v{Metadata.version}":
|
|
||||||
# INFO: find the client.zip asset
|
# INFO: find the client.zip asset
|
||||||
for asset in release["assets"]:
|
for asset in release["assets"]:
|
||||||
if asset["name"] == "client.zip":
|
if asset["name"] == "client.zip":
|
||||||
@@ -133,8 +123,35 @@ class AssetHandler:
|
|||||||
)
|
)
|
||||||
|
|
||||||
log.info("Client downloaded successfully.")
|
log.info("Client downloaded successfully.")
|
||||||
break
|
return True
|
||||||
break
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def download_client_from_github():
|
||||||
|
"""
|
||||||
|
Downloads the latest supported client from Github
|
||||||
|
and places it in the swingmusic client folder.
|
||||||
|
"""
|
||||||
|
log.error("Default client not found. Downloading from GitHub ...")
|
||||||
|
path = Paths().client_path
|
||||||
|
|
||||||
|
try:
|
||||||
|
# INFO: downlaod the current version of the client from GitHub
|
||||||
|
releases = requests.get(AssetHandler.RELEASES_URL).json()
|
||||||
|
|
||||||
|
# INFO: find the release for the current version
|
||||||
|
for release in releases:
|
||||||
|
if release["tag_name"] == f"v{Metadata.version}":
|
||||||
|
if AssetHandler.process_release(release, path):
|
||||||
|
return True
|
||||||
|
pass
|
||||||
|
|
||||||
|
# INFO: if no release is found, download the latest release
|
||||||
|
log.error(
|
||||||
|
f"No release found for the v{Metadata.version}. Downloading latest version ..."
|
||||||
|
)
|
||||||
|
return AssetHandler.process_release(releases[0], path)
|
||||||
|
|
||||||
except (
|
except (
|
||||||
requests.exceptions.RequestException,
|
requests.exceptions.RequestException,
|
||||||
|
|||||||
Reference in New Issue
Block a user