parent
a3f5232b5d
commit
84fe1b779b
3 changed files with 122 additions and 10 deletions
|
@ -1,11 +1,123 @@
|
||||||
--2024-09-29 17:54:28-- https://git.lgbt/root/posspack/raw/branch/mistress/.forgejo/scripts/update-wiki.py
|
#!/usr/bin/env python
|
||||||
Resolving git.lgbt (git.lgbt)... 213.66.116.217
|
|
||||||
Connecting to git.lgbt (git.lgbt)|213.66.116.217|:443... connected.
|
|
||||||
HTTP request sent, awaiting response... 200 OK
|
|
||||||
Length: 3328 (3.2K) [text/plain]
|
|
||||||
Saving to: ‘update-wiki.py’
|
|
||||||
|
|
||||||
0K ... 100% 677M=0s
|
from pip._vendor import requests
|
||||||
|
from pip._vendor import tomli
|
||||||
|
import json
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
2024-09-29 17:54:28 (677 MB/s) - ‘update-wiki.py’ saved [3328/3328]
|
mods = dict()
|
||||||
|
count = dict()
|
||||||
|
count["server"] = 0
|
||||||
|
count["client"] = 0
|
||||||
|
count["both"] = 0
|
||||||
|
|
||||||
|
cache = dict()
|
||||||
|
|
||||||
|
if os.path.isfile("cache/licenses.json"):
|
||||||
|
with open("cache/licenses.json", "r") as f:
|
||||||
|
cache = json.load(f)
|
||||||
|
|
||||||
|
for mod in glob.glob("pack/mods/*.toml"):
|
||||||
|
with open(mod, "r") as f:
|
||||||
|
data = tomli.load(f)
|
||||||
|
moddata = dict()
|
||||||
|
moddata["name"] = data["name"]
|
||||||
|
moddata["url"] = ""
|
||||||
|
moddata["side"] = data["side"]
|
||||||
|
license = dict()
|
||||||
|
|
||||||
|
if "modrinth" in data["update"]:
|
||||||
|
id = data["update"]["modrinth"]["mod-id"]
|
||||||
|
moddata["id"] = id
|
||||||
|
moddata["url"] = "https://modrinth.com/mod/" + id
|
||||||
|
moddata["site"] = "Modrinth"
|
||||||
|
|
||||||
|
if id in cache:
|
||||||
|
data = cache[id]
|
||||||
|
else:
|
||||||
|
data = requests.get("https://api.modrinth.com/v2/project/" + id).json()["license"]
|
||||||
|
cache[id] = data
|
||||||
|
moddata["license"] = data
|
||||||
|
elif "curseforge" in data["update"]:
|
||||||
|
moddata["url"] = "https://legacy.curseforge.com/projects/" + str(data["update"]["curseforge"]["project-id"])
|
||||||
|
moddata["site"] = "CurseForge"
|
||||||
|
|
||||||
|
count[moddata["side"]] += 1
|
||||||
|
mods[moddata["name"]] = moddata
|
||||||
|
|
||||||
|
with open("wiki/Modlist.md", "w") as f:
|
||||||
|
f.write("## Total Count\r\n")
|
||||||
|
f.write("<table>")
|
||||||
|
f.write("\r\n<tr>")
|
||||||
|
f.write("<th>Side</th>")
|
||||||
|
f.write("<th>Count</th>")
|
||||||
|
f.write("</tr>\r\n")
|
||||||
|
|
||||||
|
f.write("<tr>")
|
||||||
|
f.write("<td>Total</td>")
|
||||||
|
f.write("<td>" + str(count["server"] + count["client"] + count["both"]) + "</td>")
|
||||||
|
f.write("</tr>\r\n")
|
||||||
|
|
||||||
|
f.write("<tr>")
|
||||||
|
f.write("<td>Shared</td>")
|
||||||
|
f.write("<td>" + str(count["both"]) + "</td>")
|
||||||
|
f.write("</tr>\r\n")
|
||||||
|
|
||||||
|
f.write("<tr>")
|
||||||
|
f.write("<td>Client</td>")
|
||||||
|
f.write("<td>" + str(count["client"]) + "</td>")
|
||||||
|
f.write("</tr>\r\n")
|
||||||
|
|
||||||
|
f.write("<tr>")
|
||||||
|
f.write("<td>Server</td>")
|
||||||
|
f.write("<td>" + str(count["server"]) + "</td>")
|
||||||
|
f.write("</tr>\r\n")
|
||||||
|
|
||||||
|
f.write("</table>\r\n\r\n")
|
||||||
|
|
||||||
|
f.write("## Individual Mods\r\n")
|
||||||
|
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")
|
||||||
|
|
||||||
|
for mod in mods:
|
||||||
|
data = mods[mod]
|
||||||
|
f.write("\r\n<tr>")
|
||||||
|
f.write("<td>" + mod + "</td>")
|
||||||
|
f.write("<td>" + data["side"] + "</td>")
|
||||||
|
if data["url"] != "":
|
||||||
|
f.write("<td><a href=\"" + data["url"] + "\">" + data["site"] + "</a></td>")
|
||||||
|
else:
|
||||||
|
f.write("<td>N/A</td>")
|
||||||
|
f.write("\r\n</tr>")
|
||||||
|
f.write("\r\n</table>")
|
||||||
|
|
||||||
|
with open("wiki/Licenses.md", "w") as f:
|
||||||
|
for mod in mods:
|
||||||
|
data = mods[mod]
|
||||||
|
f.write("## " + mod + "\r\n")
|
||||||
|
f.write("<b>")
|
||||||
|
if data["site"] == "CurseForge":
|
||||||
|
f.write("CurseForge API does not provide license information, see mod page for details.")
|
||||||
|
elif "license" in data:
|
||||||
|
license = data["license"]
|
||||||
|
if license["name"] == "":
|
||||||
|
if license["id"] == "LicenseRef-Custom":
|
||||||
|
license["name"] = "Custom"
|
||||||
|
else:
|
||||||
|
license["name"] = license["id"][11:].replace("-", " ")
|
||||||
|
|
||||||
|
if license["url"] != None:
|
||||||
|
f.write("<a href=\"" + license["url"] + "\">" + license["name"] + "</a>")
|
||||||
|
else:
|
||||||
|
f.write(license["name"])
|
||||||
|
else:
|
||||||
|
f.write("Unknown")
|
||||||
|
f.write("</b>\r\n")
|
||||||
|
|
||||||
|
with open("cache/licenses.json", "w") as f:
|
||||||
|
json.dump(cache, f)
|
||||||
|
|
|
@ -2,7 +2,7 @@ hash-format = "sha256"
|
||||||
|
|
||||||
[[files]]
|
[[files]]
|
||||||
file = ".forgejo/scripts/update-wiki.py"
|
file = ".forgejo/scripts/update-wiki.py"
|
||||||
hash = "ac697fc13bb0d86899e2e57eb08a4a21ac8c77abdb16c66ae8413ccdc39e9907"
|
hash = "da922924b0fdc67aa7add46ac43745625b511c3d8ffab6291b7df002c0b9d6db"
|
||||||
|
|
||||||
[[files]]
|
[[files]]
|
||||||
file = ".forgejo/workflows/update-wiki.yaml"
|
file = ".forgejo/workflows/update-wiki.yaml"
|
||||||
|
|
|
@ -6,7 +6,7 @@ pack-format = "packwiz:1.1.0"
|
||||||
[index]
|
[index]
|
||||||
file = "index.toml"
|
file = "index.toml"
|
||||||
hash-format = "sha256"
|
hash-format = "sha256"
|
||||||
hash = "b245e20e5eee0a391976c3c5d7d2e46a9934bf46900550b6fce34e07f541e7f1"
|
hash = "acdff981e88708a60c7f97d2a77a26d98fb1ad7eaa1a91e4c7ab4fd6d05a44d5"
|
||||||
|
|
||||||
[versions]
|
[versions]
|
||||||
fabric = "0.16.5"
|
fabric = "0.16.5"
|
||||||
|
|
Loading…
Add table
Reference in a new issue