diff --git a/openGOALModLauncher.py b/openGOALModLauncher.py index e997563..843f1a7 100644 --- a/openGOALModLauncher.py +++ b/openGOALModLauncher.py @@ -274,6 +274,7 @@ def getRefreshedTableData(sort_col_idx): (mod["website_url"] if "website_url" in mod else ""), (mod["videos_url"] if "videos_url" in mod else ""), (mod["photos_url"] if "photos_url" in mod else ""), + (mod["image_override_url"] if "image_override_url" in mod else ""), ] ) @@ -433,6 +434,7 @@ def handleModTableSelection(row): mod_website_url = mod[8] mod_videos_url = mod[9] mod_photos_url = mod[10] + mod_image_override_url = mod[11] # update text and metadata window["-LAUNCH-"].update( @@ -441,6 +443,7 @@ def handleModTableSelection(row): window["-SELECTEDMODNAME-"].update(mod_name) window["-SELECTEDMODNAME-"].metadata["id"] = mod_id window["-SELECTEDMODNAME-"].metadata["url"] = mod_url + window["-SELECTEDMODNAME-"].metadata["image_override_url"] = mod_image_override_url window["-SELECTEDMODDESC-"].update(mod_desc) window["-SELECTEDMODTAGS-"].update(f"Tags: {mod_tags}") window["-SELECTEDMODCONTRIBUTORS-"].update(f"Contributors: {mod_contributors}") @@ -455,32 +458,31 @@ def handleModTableSelection(row): window["-PHOTOS-"].metadata["url"] = mod_photos_url # load mod image - mod_image_url = githubUtils.returnModImageURL(mod_url) try: - r = requests.head(mod_image_url).status_code - if r == 200: - jpg_data = ( - cloudscraper.create_scraper( - browser={ - "browser": "firefox", - "platform": "windows", - "mobile": False, - } - ) - .get(mod_image_url) - .content - ) - - pil_image = Image.open(io.BytesIO(jpg_data)) - png_bio = io.BytesIO() - pil_image.save(png_bio, format="PNG") - png_data = png_bio.getvalue() - window["-SELECTEDMODIMAGE-"].update(githubUtils.resize_image(png_data, 500.0, 300.0)) - # prints the int of the status code. Find more at httpstatusrappers.com :) - else: - window["-SELECTEDMODIMAGE-"].update(githubUtils.resize_image(noimagefile, 500.0, 300.0)) - - except requests.exceptions.MissingSchema: + mod_image_url = mod_image_override_url if mod_image_override_url != "" else githubUtils.returnModImageURL(mod_url) + r = requests.head(mod_image_url).status_code + if r == 200: + jpg_data = ( + cloudscraper.create_scraper( + browser={ + "browser": "firefox", + "platform": "windows", + "mobile": False, + } + ) + .get(mod_image_url) + .content + ) + + pil_image = Image.open(io.BytesIO(jpg_data)) + png_bio = io.BytesIO() + pil_image.save(png_bio, format="PNG") + png_data = png_bio.getvalue() + window["-SELECTEDMODIMAGE-"].update(githubUtils.resize_image(png_data, 500.0, 300.0)) + # prints the int of the status code. Find more at httpstatusrappers.com :) + else: + window["-SELECTEDMODIMAGE-"].update(githubUtils.resize_image(noimagefile, 500.0, 300.0)) + except: window["-SELECTEDMODIMAGE-"].update(githubUtils.resize_image(noimagefile, 500.0, 300.0)) diff --git a/resources/jak1_mods.json b/resources/jak1_mods.json index 39f42c7..394da69 100644 --- a/resources/jak1_mods.json +++ b/resources/jak1_mods.json @@ -423,5 +423,19 @@ "release_date": "2023-07-05", "URL": "https://github.com/OpenGOAL-Mods/OG-Invisible-Legacy/releases", "website_url": "https://github.com/OpenGOAL-Mods/OG-Invisible-Legacy" + }, + "orange_demon": { + "name": "Orange Demon Challenge", + "desc": "Play through the entire game while being chased by Daxter!", + "contributors": ["Hat Kid"], + "tags": [ + "gameplay-mod", + "custom-enemy", + "challenge" + ], + "release_date": "2023-07-09", + "URL": "https://github.com/Hat-Kid/jak-project/releases", + "image_override_url": "https://cdn.discordapp.com/attachments/1124072608548266105/1127708472394391653/orange-demon-thumb.png", + "website_url": "https://gist.github.com/Hat-Kid/ede85d11ecf98f89f1e857160cdf82c7" } } diff --git a/utils/launcherUtils.py b/utils/launcherUtils.py index f0a4e74..a61cc44 100644 --- a/utils/launcherUtils.py +++ b/utils/launcherUtils.py @@ -251,7 +251,8 @@ def launch(URL, MOD_ID, MOD_NAME, LINK_TYPE): # Github API Call launchUrl = URL if LINK_TYPE == githubUtils.LinkTypes.BRANCH: - launchUrl = githubUtils.branchToApiURL(URL) + launchUrl = githubUtils.branchToApiURL(URL) + LatestRelAssetsURL = "" print("\nlaunching from " + launchUrl) PARAMS = {"address": "yolo"} @@ -272,30 +273,29 @@ def launch(URL, MOD_ID, MOD_NAME, LINK_TYPE): # store Latest Release and check our local date too. if LINK_TYPE == githubUtils.LinkTypes.BRANCH: - LatestRel = datetime.strptime( - r.get("commit") - .get("commit") - .get("author") - .get("date") - .replace("T", " ") - .replace("Z", ""), - "%Y-%m-%d %H:%M:%S", - ) - LatestRelAssetsURL = githubUtils.branchToArchiveURL(URL) + LatestRel = datetime.strptime( + r.get("commit") + .get("commit") + .get("author") + .get("date") + .replace("T", " ") + .replace("Z", ""), + "%Y-%m-%d %H:%M:%S", + ) + LatestRelAssetsURL = githubUtils.branchToArchiveURL(URL) elif LINK_TYPE == githubUtils.LinkTypes.RELEASE: - LatestRel = datetime.strptime( - r[0].get("published_at").replace("T", " ").replace("Z", ""), - "%Y-%m-%d %H:%M:%S", - ) - LatestRelAssetsURL = ( - json.loads( - json.dumps( - requests.get(url=r[0].get("assets_url"), params=PARAMS).json() - ) - ) - )[0].get("browser_download_url") - response = requests.get(url=LatestRelAssetsURL, params=PARAMS) - content_type = response.headers["content-type"] + LatestRel = datetime.strptime( + r[0].get("published_at").replace("T", " ").replace("Z", ""), + "%Y-%m-%d %H:%M:%S", + ) + assets = json.loads(json.dumps(requests.get(url=r[0].get("assets_url"), params=PARAMS).json())) + for asset in assets: + if "linux" not in asset.get("name"): + LatestRelAssetsURL = asset.get("browser_download_url") + break + + # response = requests.get(url=LatestRelAssetsURL, params=PARAMS) + # content_type = response.headers["content-type"] LastWrite = datetime(2020, 5, 17) if exists(InstallDir + "/" + ExecutableName):