From 0cf5830671c4cc8e3545178d31841fa4d10ffffc Mon Sep 17 00:00:00 2001 From: MacRimi <123239993+MacRimi@users.noreply.github.com> Date: Tue, 3 Jun 2025 11:09:29 +0200 Subject: [PATCH] Actualizar generate_helpers_cache.py --- .github/scripts/generate_helpers_cache.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/scripts/generate_helpers_cache.py b/.github/scripts/generate_helpers_cache.py index fce556a..c142530 100644 --- a/.github/scripts/generate_helpers_cache.py +++ b/.github/scripts/generate_helpers_cache.py @@ -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.") \ No newline at end of file +print(f"✅ helpers_cache.json created at {OUTPUT_FILE} with {len(cache)} valid scripts.") \ No newline at end of file