Files
JIANT/web/fetch_prev.py
T
Claude 6992e47e86 v0.6.46: INIT dry, FM6 init voice, NEW PROJECT, NOISE DUST, earlier versions in the installer
User feedback: INIT SOUND sets every effect send to 0 and loads FM6's
init voice (OP1 alone) instead of a factory patch; INIT SYSTEM is now
NEW PROJECT and starts every track that way; NOISE DUST at DENS 0 still
crackles; FM6's chart shows the algorithm's number with ALG on PAT. The
web installer keeps the last few versions installable (fetch_prev.py,
versions.json) and links the manual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-10-12 13:18:20 +00:00

54 lines
2.0 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
"""(JIANT 0.6.46) The packages the live site holds now, for make_site.py's PREV_DIR (the earlier versions the
installer keeps offering). The site lists them in firmware/versions.json; a site from before that has one package,
named in the installer's metadata. Nothing found is no error: the new site then has the current version only.
web/fetch_prev.py SITE_URL OUT_DIR"""
import json
import re
import sys
import urllib.request
from pathlib import Path
SAFE = re.compile(r"felucca-[A-Za-z0-9.-]+\.fwsc")
def get(url):
with urllib.request.urlopen(url, timeout=60) as r:
return r.read()
def main(site, out):
site, out = site.rstrip("/"), Path(out)
out.mkdir(parents=True, exist_ok=True)
try:
listed = json.loads(get(site + "/firmware/versions.json"))
except Exception:
listed = []
try: # an older site: the installer's one package
html = get(site + "/webapp/installer/").decode("utf-8", "replace")
m = re.search(r'"version": "([^"]+)", "product": "[^"]+", "pkg": "\.\./\.\./firmware/(felucca-[^"]+)"', html)
if m:
listed = [{"version": m.group(1), "file": m.group(2)}]
except Exception as e:
print(f"fetch_prev: nothing from {site}: {e}")
kept = []
for e in listed[:12] if isinstance(listed, list) else []:
f = str(e.get("file", ""))
if not SAFE.fullmatch(f):
continue
try:
(out / f).write_bytes(get(f"{site}/firmware/{f}"))
kept.append({"version": str(e.get("version", "")), "file": f})
except Exception as x:
print(f"fetch_prev: {f}: {x}")
(out / "versions.json").write_text(json.dumps(kept) + "\n", encoding="utf-8")
print(f"fetch_prev: {len(kept)} earlier package(s): {' '.join(e['version'] for e in kept)}")
if __name__ == "__main__":
if len(sys.argv) != 3:
sys.exit(__doc__)
main(*sys.argv[1:3])