64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""Fetch bounded exact source texts only; never install or import upstream code."""
|
|
|
|
import hashlib
|
|
import json
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
OUT = ROOT / "docs/hel-892/frames-reference"
|
|
SPECS = [
|
|
(
|
|
"kj",
|
|
"kijai/ComfyUI-KJNodes",
|
|
"a9ab19d2a7933e03f72bc00103863f06b9483300",
|
|
["__init__.py", "nodes/image_nodes.py", "web/js/jsnodes.js", "LICENSE"],
|
|
),
|
|
(
|
|
"core16",
|
|
"Comfy-Org/ComfyUI",
|
|
"1c218282369a6cc80651d878fc51fa33d7bf34e2",
|
|
["nodes.py", "LICENSE"],
|
|
),
|
|
(
|
|
"core03",
|
|
"Comfy-Org/ComfyUI",
|
|
"c55fd7481626d8bee8044ea7512ea996d13a1b90",
|
|
["nodes.py", "LICENSE"],
|
|
),
|
|
]
|
|
|
|
|
|
def main():
|
|
entries = []
|
|
for key, repo, commit, files in SPECS:
|
|
for file in files:
|
|
name = key + "__" + file.replace("/", "__")
|
|
url = f"https://raw.githubusercontent.com/{repo}/{commit}/{file}"
|
|
target = OUT / name
|
|
if not target.exists():
|
|
with urllib.request.urlopen(url, timeout=40) as response:
|
|
raw = response.read(2_000_000)
|
|
target.write_bytes(raw)
|
|
entries.append(
|
|
dict(
|
|
id=key,
|
|
file=file,
|
|
local_file=name,
|
|
url=url,
|
|
commit=commit,
|
|
sha256=hashlib.sha256(target.read_bytes()).hexdigest(),
|
|
)
|
|
)
|
|
for key, folder in [("vhs177", "reverse-reference"), ("vhs179", "concat-reference")]:
|
|
for e in json.loads((OUT.parent / folder / "sources.json").read_bytes())["sources"]:
|
|
if e["id"] == "vhs":
|
|
entries.append({**e, "id": key, "local_file": f"../{folder}/" + e["local_file"]})
|
|
(OUT / "sources.json").write_text(
|
|
json.dumps(dict(sources=entries), ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|