2024-07-27 14:23:23 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2024-08-01 01:13:22 +02:00
|
|
|
from pip._vendor import requests
|
2024-07-27 14:41:57 +02:00
|
|
|
from pip._vendor import tomli
|
2024-08-01 01:25:56 +02:00
|
|
|
import json
|
2024-07-27 14:28:16 +02:00
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
|
2024-07-27 14:48:06 +02:00
|
|
|
mods = dict()
|
2024-07-28 22:39:28 +02:00
|
|
|
count = dict()
|
|
|
|
count["server"] = 0
|
|
|
|
count["client"] = 0
|
|
|
|
count["both"] = 0
|
2024-07-27 14:48:06 +02:00
|
|
|
|
2024-08-01 01:25:56 +02:00
|
|
|
cache = dict()
|
2024-08-01 01:27:21 +02:00
|
|
|
|
|
|
|
with open("licenses.json") as f:
|
|
|
|
cache = json.load(f)
|
2024-08-01 01:25:56 +02:00
|
|
|
|
2024-07-27 14:31:45 +02:00
|
|
|
for mod in glob.glob("pack/mods/*.toml"):
|
2024-07-27 14:44:02 +02:00
|
|
|
with open(mod, "r") as f:
|
2024-07-27 14:41:57 +02:00
|
|
|
data = tomli.load(f)
|
2024-07-27 15:43:27 +02:00
|
|
|
moddata = dict()
|
2024-08-01 01:15:41 +02:00
|
|
|
moddata["name"] = data["name"]
|
2024-07-27 15:43:27 +02:00
|
|
|
moddata["url"] = ""
|
2024-08-01 01:15:41 +02:00
|
|
|
moddata["side"] = data["side"]
|
2024-07-27 14:52:33 +02:00
|
|
|
|
2024-07-27 14:55:11 +02:00
|
|
|
if "modrinth" in data["update"]:
|
2024-08-01 01:12:46 +02:00
|
|
|
id = data["update"]["modrinth"]["mod-id"]
|
|
|
|
moddata["id"] = id
|
|
|
|
moddata["url"] = "https://modrinth.com/mod/" + id
|
2024-07-27 15:43:27 +02:00
|
|
|
moddata["site"] = "Modrinth"
|
2024-08-01 01:12:46 +02:00
|
|
|
|
2024-08-01 01:24:29 +02:00
|
|
|
if moddata["name"] in cache:
|
2024-08-01 01:27:21 +02:00
|
|
|
data = cache[id]
|
2024-08-01 01:24:29 +02:00
|
|
|
else:
|
|
|
|
data = requests.get("https://api.modrinth.com/v2/project/" + id).json()["license"]
|
2024-08-01 01:27:21 +02:00
|
|
|
cache[id] = data
|
2024-07-27 14:55:11 +02:00
|
|
|
elif "curseforge" in data["update"]:
|
2024-07-27 15:43:27 +02:00
|
|
|
moddata["url"] = "https://legacy.curseforge.com/projects/" + str(data["update"]["curseforge"]["project-id"])
|
|
|
|
moddata["site"] = "CurseForge"
|
2024-07-27 14:52:33 +02:00
|
|
|
|
2024-08-01 01:15:41 +02:00
|
|
|
count[moddata["side"]] += 1
|
|
|
|
mods[moddata["name"]] = moddata
|
2024-07-27 14:48:06 +02:00
|
|
|
|
|
|
|
with open("wiki/Modlist.md", "w") as f:
|
2024-07-28 22:40:16 +02:00
|
|
|
f.write("## Total Count\r\n")
|
2024-07-28 22:39:28 +02:00
|
|
|
f.write("<table>")
|
|
|
|
f.write("\r\n<tr>")
|
|
|
|
f.write("<th>Side</th>")
|
|
|
|
f.write("<th>Count</th>")
|
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
2024-07-28 22:43:28 +02:00
|
|
|
f.write("<tr>")
|
|
|
|
f.write("<td>Total</td>")
|
|
|
|
f.write("<td>" + str(count["server"] + count["client"] + count["both"]) + "</td>")
|
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
2024-07-28 22:42:02 +02:00
|
|
|
f.write("<tr>")
|
|
|
|
f.write("<td>Shared</td>")
|
|
|
|
f.write("<td>" + str(count["both"]) + "</td>")
|
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
|
|
|
f.write("<tr>")
|
2024-07-28 22:39:28 +02:00
|
|
|
f.write("<td>Client</td>")
|
2024-07-28 22:41:17 +02:00
|
|
|
f.write("<td>" + str(count["client"]) + "</td>")
|
2024-07-28 22:39:28 +02:00
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
2024-07-28 22:42:02 +02:00
|
|
|
f.write("<tr>")
|
2024-07-28 22:39:28 +02:00
|
|
|
f.write("<td>Server</td>")
|
2024-07-28 22:41:17 +02:00
|
|
|
f.write("<td>" + str(count["server"]) + "</td>")
|
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
2024-07-28 22:42:27 +02:00
|
|
|
f.write("</table>\r\n\r\n")
|
2024-07-28 22:39:28 +02:00
|
|
|
|
2024-07-28 22:40:16 +02:00
|
|
|
f.write("## Individual Mods\r\n")
|
2024-07-27 15:43:27 +02:00
|
|
|
f.write("<table>")
|
|
|
|
f.write("\r\n<tr>")
|
|
|
|
f.write("<th>Name</th>")
|
|
|
|
f.write("<th>Side</th>")
|
|
|
|
f.write("<th>Link</th>")
|
|
|
|
f.write("</tr>\r\n")
|
|
|
|
|
2024-07-27 14:48:06 +02:00
|
|
|
for mod in mods:
|
2024-08-01 01:10:17 +02:00
|
|
|
data = mods[mod]
|
2024-07-27 15:43:27 +02:00
|
|
|
f.write("\r\n<tr>")
|
|
|
|
f.write("<td>" + mod + "</td>")
|
2024-08-01 01:10:17 +02:00
|
|
|
f.write("<td>" + data["side"] + "</td>")
|
|
|
|
if data["url"] != "":
|
|
|
|
f.write("<td><a href=\"" + data["url"] + "\">" + data["site"] + "</a></td>")
|
2024-07-27 14:49:15 +02:00
|
|
|
else:
|
2024-07-27 15:43:27 +02:00
|
|
|
f.write("<td>N/A</td>")
|
2024-07-29 16:25:52 +02:00
|
|
|
f.write("\r\n</tr>")
|
2024-07-28 22:39:28 +02:00
|
|
|
f.write("\r\n</table>")
|
2024-08-01 01:10:17 +02:00
|
|
|
|
|
|
|
with open("wiki/Licenses.md", "w") as f:
|
|
|
|
for mod in mods:
|
|
|
|
data = mods[mod]
|
|
|
|
f.write("## " + mod + "\r\n")
|
|
|
|
f.write("<b>")
|
2024-08-01 01:21:44 +02:00
|
|
|
if "license" in data:
|
2024-08-01 01:17:06 +02:00
|
|
|
if data["license"]["url"] != None:
|
|
|
|
f.write("<a href=\"" + data["license"]["url"] + "\">" + data["license"] + "")
|
|
|
|
else:
|
|
|
|
f.write(data["license"]["name"])
|
2024-08-01 01:10:17 +02:00
|
|
|
else:
|
2024-08-01 01:17:06 +02:00
|
|
|
f.write("Unknown")
|
2024-08-01 01:10:17 +02:00
|
|
|
f.write("</b>\r\n")
|
2024-08-01 01:27:21 +02:00
|
|
|
|
|
|
|
with open("licenses.json") as f:
|
|
|
|
json.dump(cache, f)
|