mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 04:06:54 +00:00
Update generate_helpers_cache.py
This commit is contained in:
parent
84f5897e38
commit
78064cc07c
15
.github/scripts/generate_helpers_cache.py
vendored
15
.github/scripts/generate_helpers_cache.py
vendored
@ -1,8 +1,13 @@
|
|||||||
import requests, json
|
import requests, json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# GitHub API URL to fetch all .json files describing scripts
|
||||||
API_URL = "https://api.github.com/repos/community-scripts/ProxmoxVE/contents/frontend/public/json"
|
API_URL = "https://api.github.com/repos/community-scripts/ProxmoxVE/contents/frontend/public/json"
|
||||||
|
|
||||||
|
# Base path to build the full URL for the installable scripts
|
||||||
SCRIPT_BASE = "https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/scripts"
|
SCRIPT_BASE = "https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/scripts"
|
||||||
|
|
||||||
|
# Output file where the consolidated helper scripts cache will be stored
|
||||||
OUTPUT_FILE = Path("json/helpers_cache.json")
|
OUTPUT_FILE = Path("json/helpers_cache.json")
|
||||||
OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
@ -10,6 +15,7 @@ res = requests.get(API_URL)
|
|||||||
data = res.json()
|
data = res.json()
|
||||||
cache = []
|
cache = []
|
||||||
|
|
||||||
|
# Loop over each file in the JSON directory
|
||||||
for item in data:
|
for item in data:
|
||||||
url = item.get("download_url")
|
url = item.get("download_url")
|
||||||
if not url or not url.endswith(".json"):
|
if not url or not url.endswith(".json"):
|
||||||
@ -21,17 +27,19 @@ for item in data:
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Extract fields required to identify a valid helper script
|
||||||
|
name = raw.get("name", "")
|
||||||
slug = raw.get("slug")
|
slug = raw.get("slug")
|
||||||
script = raw.get("install_methods", [{}])[0].get("script", "")
|
script = raw.get("install_methods", [{}])[0].get("script", "")
|
||||||
if not slug or not script:
|
if not slug or not script:
|
||||||
continue
|
continue # Skip if it's not a valid script
|
||||||
|
|
||||||
desc = raw.get("description", "")
|
desc = raw.get("description", "")
|
||||||
categories = raw.get("categories", [])
|
categories = raw.get("categories", [])
|
||||||
notes = [note.get("text", "") for note in raw.get("notes", []) if isinstance(note, dict)]
|
notes = [note.get("text", "") for note in raw.get("notes", []) if isinstance(note, dict)]
|
||||||
|
|
||||||
full_script_url = f"{SCRIPT_BASE}/{script}"
|
full_script_url = f"{SCRIPT_BASE}/{script}"
|
||||||
|
|
||||||
|
# Append the script metadata to the cache
|
||||||
cache.append({
|
cache.append({
|
||||||
"name": name,
|
"name": name,
|
||||||
"slug": slug,
|
"slug": slug,
|
||||||
@ -42,7 +50,8 @@ for item in data:
|
|||||||
"notes": notes
|
"notes": notes
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Write the JSON cache to disk
|
||||||
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
|
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
|
||||||
json.dump(cache, f, indent=2)
|
json.dump(cache, f, indent=2)
|
||||||
|
|
||||||
print(f"â
helpers_cache.json created at {OUTPUT_FILE} with {len(cache)} valid scripts.")
|
print(f"✅ helpers_cache.json created at {OUTPUT_FILE} with {len(cache)} valid scripts.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user