Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find appropriate URL for given forge version #25

Merged
merged 3 commits into from Feb 7, 2023
Merged

Find appropriate URL for given forge version #25

merged 3 commits into from Feb 7, 2023

Conversation

the-be-to
Copy link
Contributor

The URL for the Forge download is currently assumed to be in the form of '.../forge/%s/forge-%s-installer.jar' % (forge_fullver, forge_fullver), but upon inspecting various versions, there is a greater variety. e.g
Minecraft 1.7.10, Forge 10.13.4.1614: .../forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar
Minecraft 1.7.10, Forge 10.13.3.1395: .../forge/1.7.10-10.13.3.1395-1710ls/forge-1.7.10-10.13.3.1395-1710ls-installer.jar
A function get_forge_url() was implemented to obtain the required download URL by scraping the Forge download page for the specified Minecraft version, and using a regex to find the appropriate URL for the specified Forge version.
The following shows its use:

Python 3.10.9 (main, Dec 25 2022, 21:29:15) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from forge_install import get_forge_url
>>> get_forge_url("1.7.10", "10.13.4.1614")
Downloading https://files.minecraftforge.net/net/minecraftforge/forge/index_1.7.10.html
'https://maven.minecraftforge.net/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar'
>>> get_forge_url("1.7.10", "10.13.3.1395")
'https://maven.minecraftforge.net/net/minecraftforge/forge/1.7.10-10.13.3.1395-1710ls/forge-1.7.10-10.13.3.1395-1710ls-installer.jar'
>>> get_forge_url("1.12.2", "14.23.5.2860")
Downloading https://files.minecraftforge.net/net/minecraftforge/forge/index_1.12.2.html
'https://maven.minecraftforge.net/net/minecraftforge/forge/1.12.2-14.23.5.2860/forge-1.12.2-14.23.5.2860-installer.jar'

This resolves the issue noted in #16.

@cdbbnnyCode
Copy link
Owner

Looks good; I'd suggest adding a fallback in case the HTML scraper fails, since the default pattern still applies for most versions.

@cdbbnnyCode cdbbnnyCode merged commit 7691391 into cdbbnnyCode:master Feb 7, 2023
@the-be-to the-be-to deleted the forge-url-fix branch February 7, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants