commit
a41caabb97
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,3 +1,8 @@
|
||||||
.gradle
|
.gradle
|
||||||
.idea
|
.idea
|
||||||
build
|
build
|
||||||
|
.settings
|
||||||
|
.project
|
||||||
|
.vscode
|
||||||
|
mods
|
||||||
|
mods.csv
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
# anvilcraft3
|
# Anvilcraft3 tweaked fork by LordMZTE
|
||||||
Execute gradlew buildTwitch to create the Twitch zip file in build/libs
|
- Execute `gradlew buildTwitch`
|
||||||
|
- To create the **Twitch Import** zip file in **build/lib**
|
||||||
|
- Execute `python downloadMods.py`
|
||||||
|
- To download all mods into **/mods/**
|
||||||
|
- Execute `python getModlist.py`
|
||||||
|
- To create a **mods.csv** file containing the names, authors, curseforge links, download count and ID of all mods
|
||||||
|
|
51
downloadMods.py
Normal file
51
downloadMods.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import json
|
||||||
|
from urllib import request
|
||||||
|
import ntpath
|
||||||
|
import os
|
||||||
|
|
||||||
|
#Constants:
|
||||||
|
manifestlocation="src/twitch/manifest.json"
|
||||||
|
|
||||||
|
def tryGetLink(projectID: str, fileID: str):
|
||||||
|
while(True):
|
||||||
|
url = "https://addons-ecs.forgesvc.net/api/v2/addon/" + projectID + "/file/" + fileID + "/download-url"
|
||||||
|
try:
|
||||||
|
return request.urlopen(url, timeout=10000)
|
||||||
|
except:
|
||||||
|
print("Failed to get Download Link for " + url + " retrying...")
|
||||||
|
|
||||||
|
|
||||||
|
if os.path.exists("mods"):
|
||||||
|
if os.listdir("mods"):
|
||||||
|
print("mods directory is not empty, delete or empty")
|
||||||
|
quit()
|
||||||
|
else:
|
||||||
|
os.mkdir("mods")
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(manifestlocation, "r") as manifestfile:
|
||||||
|
manifestdata = manifestfile.read()
|
||||||
|
except:
|
||||||
|
print("manifest not found")
|
||||||
|
quit()
|
||||||
|
manifestobj = json.loads(manifestdata)
|
||||||
|
|
||||||
|
downloadLinks = []
|
||||||
|
filecount = len(manifestobj["files"])
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for file in manifestobj["files"]:
|
||||||
|
i += 1
|
||||||
|
with tryGetLink(str(file["projectID"]), str(file["fileID"])) as response:
|
||||||
|
responseLink = response.read().decode("utf-8")
|
||||||
|
downloadLinks.append(responseLink)
|
||||||
|
print("(" + str(i) + "/" + str(filecount) + ") Got Download Link For " + ntpath.basename(responseLink))
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
filecount = len(downloadLinks)
|
||||||
|
for link in downloadLinks:
|
||||||
|
i += 1
|
||||||
|
filename = ntpath.basename(link)
|
||||||
|
request.urlretrieve(link.replace(" ", "%20"), "mods/" + filename)
|
||||||
|
print("(" + str(i) + "/" + str(filecount) + ") Downloaded " + filename)
|
78
getModlist.py
Normal file
78
getModlist.py
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
from urllib import request
|
||||||
|
import json
|
||||||
|
from os import path
|
||||||
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
#Constants
|
||||||
|
manifestlocation="src/twitch/manifest.json"
|
||||||
|
|
||||||
|
if path.isfile("mods.csv"):
|
||||||
|
print("Delete mods.csv")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(manifestlocation, "r") as manifestfile:
|
||||||
|
manifestjson = json.loads(manifestfile.read())
|
||||||
|
except:
|
||||||
|
print("manifest not found")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
projectIDs = []
|
||||||
|
|
||||||
|
for file in manifestjson["files"]:
|
||||||
|
projectIDs.append(file["projectID"])
|
||||||
|
|
||||||
|
filesInBytes = str(projectIDs).encode("utf-8")
|
||||||
|
|
||||||
|
req = request.Request("https://addons-ecs.forgesvc.net/api/v2/addon",
|
||||||
|
data = filesInBytes,
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36',
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
})
|
||||||
|
|
||||||
|
print("Getting Mod names from Twitch API")
|
||||||
|
with request.urlopen(req) as request:
|
||||||
|
response = request.read()
|
||||||
|
response = response.decode("ascii", "ignore")
|
||||||
|
apireturn = json.loads(response)
|
||||||
|
|
||||||
|
print("Formatting")
|
||||||
|
mods = []
|
||||||
|
for mod in apireturn:
|
||||||
|
modDict = {}
|
||||||
|
|
||||||
|
modDict["name"] = mod["name"]
|
||||||
|
modDict["id"] = mod["id"]
|
||||||
|
modDict["url"] = mod["websiteUrl"]
|
||||||
|
modDict["downloads"] = mod["downloadCount"]
|
||||||
|
|
||||||
|
authorStr = ""
|
||||||
|
for author in mod["authors"]:
|
||||||
|
authorStr += ", " + author["name"]
|
||||||
|
authorStr = authorStr.strip(", ")
|
||||||
|
modDict["authors"] = authorStr
|
||||||
|
|
||||||
|
mods.append(modDict)
|
||||||
|
|
||||||
|
with open("mods.csv", "w", newline = "") as modFile:
|
||||||
|
writer = csv.writer(modFile, delimiter=';', quoting=csv.QUOTE_MINIMAL)
|
||||||
|
|
||||||
|
#Write Header
|
||||||
|
writer.writerow(["Mod Name", "Authors", "Link", "Downloads", "ID"])
|
||||||
|
writer.writerow([])
|
||||||
|
|
||||||
|
#Write Data
|
||||||
|
print("Writing CSV")
|
||||||
|
for mod in mods:
|
||||||
|
toWrite = []
|
||||||
|
|
||||||
|
toWrite.append(mod["name"])
|
||||||
|
toWrite.append(mod["authors"])
|
||||||
|
toWrite.append(mod["url"])
|
||||||
|
toWrite.append(str(int(mod["downloads"])))
|
||||||
|
toWrite.append(str(int(mod["id"])))
|
||||||
|
|
||||||
|
writer.writerow(toWrite)
|
||||||
|
print("done")
|
|
@ -10,9 +10,9 @@
|
||||||
},
|
},
|
||||||
"manifestType": "minecraftModpack",
|
"manifestType": "minecraftModpack",
|
||||||
"manifestVersion": 1,
|
"manifestVersion": 1,
|
||||||
"name": "Anvilcraft",
|
"name": "Anvilcraft MZTE Fork",
|
||||||
"version": "3.0-BETA",
|
"version": "3.0-BETA",
|
||||||
"author": "mpztilera",
|
"author": "mpztilera, LordMZTE",
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"projectID": 248425,
|
"projectID": 248425,
|
||||||
|
|
Loading…
Reference in a new issue