Inital Commit

This commit is contained in:
Firepup Sixfifty 2024-09-17 21:31:30 -05:00
commit 553906b2da
Signed by: Firepup650
SSH key fingerprint: SHA256:cb8sEJwc0kQJ6/nMUhscWRe35itf0NFMdSKl3v4qt48
2 changed files with 62 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

61
update-plugins.py Normal file
View file

@ -0,0 +1,61 @@
from dotenv import load_dotenv
from os import environ as env
from requests import request
# Try to load cache
print("[[ Info ]] Trying to load installed versions from cache...")
knownVersions = {}
try:
from cache import knownVersions
print(f"[[ Info ]] Loaded {len(knownVersions)} installed versions from cache...")
except ImportError:
# Fallback to just a warning
print("""[[ Warn ]] Failed to load versions from cache
[[ Warn ]] If this is not your first time running this script, it's recommended you investigate why.""")
load_dotenv()
hangarPlugins = {
# "slug-of-plugin": {"Channel": "channel-to-pull", "Version": 'version-to-pull or "latest"'}
}
spigotPlugins = {
# "resource-id-of-plugin": {"Version": 'version-id-to-pull or "latest"'}
}
geyser = True
floodgate = True
if hangarPlugins and not env.get("HANGAR_KEY", ""):
print(
"""!! Notice !! This script cannot download hangar plugins without a hangar api key!
!! Notice !! Please signup for an account at https://hangar.papermc.io/auth/signup
!! Notice !! Then generate an api key with the "view_public_info" permission at https://hangar.papermc.io/auth/settings/api-keys
!! Notice !! Since there's no hangar api key, the defined list of hangar plugins will be COMPLETELY IGNORED on this run."""
)
hangarPlugins = {}
if hangarPlugins:
for plugin in hangarPlugins:
# check
# download update
# update version storage to match
...
if spigotPlugins:
for plugin in spigotPlugins:
version = spigotPlugins[plugin]["Version"]
if spigotPlugins[plugin]["Version"] == "latest":
version = le(request("GET", "https://api.spiget.org/v2/resources/60310/versions/latest").text)["id"]
if not knownVersions.get(plugin, "") or knownVersions[plugin] != version:
# download update
knownVersions[plugin] = version
if geyser:
# download https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot
...
if floodgate:
# download https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot
...
# write cache file