downloadMods.py will now dowload mods from the modpackjson file

This commit is contained in:
LordMZTE 2020-05-15 23:50:03 +02:00
parent ba4ffdafc2
commit 38d07cea65

View file

@ -5,6 +5,7 @@ import os
#Constants:
manifestlocation="src/twitch/manifest.json"
modpackjsonLocation="src/addonscript/modpack.json"
def tryGetLink(projectID: str, fileID: str):
while(True):
@ -42,6 +43,22 @@ for file in manifestobj["files"]:
downloadLinks.append(responseLink)
print("(" + str(i) + "/" + str(filecount) + ") Got Download Link For " + ntpath.basename(responseLink))
#Yes i know this is very unclean but this script will be replaced with modpacktools later anyways
try:
with open(modpackjsonLocation) as modpackjsonfile:
modpackjsondata = modpackjsonfile.read()
except:
print("Modpackjson Not found!")
quit()
modpackjsonobject = json.loads(modpackjsondata)
modpackjsonrelations = modpackjsonobject["versions"][0]["relations"]
for relation in modpackjsonrelations:
if relation["linkType"] == "file":
downloadLinks.append(relation["link"])
print("Got link for modpackjson mod " + ntpath.basename(relation["link"]))
i = 0
filecount = len(downloadLinks)
for link in downloadLinks: