Update Modrinth API to V2
This commit is contained in:
parent
85f99ea3d3
commit
fb4269f85f
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user