Skip to content

Commit

Permalink
Merge pull request #27 from OpenGOAL-Unofficial-Mods/orange-demon-plu…
Browse files Browse the repository at this point in the history
…s-release-cleanup

fix how we choose release asset for use, add hatkids mod
  • Loading branch information
Zedb0T authored Jul 9, 2023
2 parents f30d940 + c6e73da commit e1883ba
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
52 changes: 27 additions & 25 deletions openGOALModLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""),
]
)

Expand Down Expand Up @@ -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(
Expand All @@ -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}")
Expand All @@ -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))


Expand Down
14 changes: 14 additions & 0 deletions resources/jak1_mods.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
48 changes: 24 additions & 24 deletions utils/launcherUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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):
Expand Down

0 comments on commit e1883ba

Please sign in to comment.