From fb4269f85f6122045684db5c042f5819c1d854f8 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Tue, 2 Aug 2022 17:51:49 -0500 Subject: [PATCH] Update Modrinth API to V2 --- parsers/modrinth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsers/modrinth.py b/parsers/modrinth.py index 5a0a875..2e91c84 100644 --- a/parsers/modrinth.py +++ b/parsers/modrinth.py @@ -24,7 +24,7 @@ if debug == True: #regex = re.compile(r'*') # Setup session, this lets the parser re-use the connection instead of establishing a new connection for EACH request, not only does this cause a HUGE performance boost, it's also nicer to the API. session = requests.Session() -base_api_url = "https://api.modrinth.com:443/api/v1" +base_api_url = "https://api.modrinth.com:443/v2" def failCheck(response, functOrigin): print("Status Code is: "+str(response.status_code)) if response.status_code == 429: @@ -50,7 +50,7 @@ def modInfo(project): print("Returning cached data!") return dataCache["modInfo"] else: - response = session.get(base_api_url+"/mod/"+project, family=socket.AF_INET) + response = session.get(base_api_url+"/project/"+project, family=socket.AF_INET) if failCheck(response, "modInfo") == True: #Attempt to requery API response = session.get(base_api_url+"/mod/"+project, family=socket.AF_INET) api_response = response.json() @@ -220,6 +220,7 @@ def getLatestStable(project): print("Calling getLatestStable()...") versions = getVersions(project) build_type = determine(project, "Release") + # Build a dictionary that ties the versions to the build type build_type_dict = {} number_of_versions = len(versions)