mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-27 20:06:52 +00:00
Actualizar generate_helpers_cache.py
This commit is contained in:
parent
f25d8aec3c
commit
0cf5830671
20
.github/scripts/generate_helpers_cache.py
vendored
20
.github/scripts/generate_helpers_cache.py
vendored
@ -1,20 +1,15 @@
|
||||
import requests, json
|
||||
from pathlib import Path
|
||||
|
||||
# GitHub API endpoint for JSON script definitions
|
||||
API_URL = "https://api.github.com/repos/community-scripts/ProxmoxVE/contents/frontend/public/json"
|
||||
|
||||
# Base URL where .sh install scripts are hosted
|
||||
SCRIPT_BASE = "https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/scripts"
|
||||
OUTPUT_FILE = Path("json/helpers_cache.json")
|
||||
OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Output filename for the generated cache
|
||||
OUTPUT_FILE = "helpers_cache.json"
|
||||
|
||||
# Fetch list of JSON files
|
||||
res = requests.get(API_URL)
|
||||
data = res.json()
|
||||
cache = []
|
||||
|
||||
# Process each JSON file
|
||||
for item in data:
|
||||
url = item.get("download_url")
|
||||
if not url or not url.endswith(".json"):
|
||||
@ -26,21 +21,17 @@ for item in data:
|
||||
except:
|
||||
continue
|
||||
|
||||
# Extract mandatory fields
|
||||
slug = raw.get("slug")
|
||||
script = raw.get("install_methods", [{}])[0].get("script", "")
|
||||
if not slug or not script:
|
||||
continue # skip non-script or invalid entries
|
||||
continue
|
||||
|
||||
# Extract optional fields
|
||||
desc = raw.get("description", "")
|
||||
categories = raw.get("categories", [])
|
||||
notes = [note.get("text", "") for note in raw.get("notes", []) if isinstance(note, dict)]
|
||||
|
||||
# Construct full URL to the install script
|
||||
full_script_url = f"{SCRIPT_BASE}/{script}"
|
||||
|
||||
# Append script info to cache list
|
||||
cache.append({
|
||||
"slug": slug,
|
||||
"desc": desc,
|
||||
@ -50,8 +41,7 @@ for item in data:
|
||||
"notes": notes
|
||||
})
|
||||
|
||||
# Write the full cache to JSON file
|
||||
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump(cache, f, indent=2)
|
||||
|
||||
print(f"✅ helpers_cache.json created 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