96 lines
3.0 KiB
Python
96 lines
3.0 KiB
Python
"""Fetch only exact commit textual originals and tree metadata; no plugin import."""
|
|
|
|
import concurrent.futures
|
|
import hashlib
|
|
import json
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
OUT = Path(__file__).resolve().parent
|
|
REF = OUT.parent / "multivideo-reference"
|
|
PINS = {
|
|
"concat": (
|
|
"kijai/ComfyUI-KJNodes",
|
|
"ff7f876c09ff5a53be051073c3c1731b96ee31a3",
|
|
["__init__.py", "nodes/image_nodes.py", "web/js/jsnodes.js", "LICENSE"],
|
|
),
|
|
"resize": (
|
|
"kijai/ComfyUI-KJNodes",
|
|
"50e7dd34d3b6e6bbab1d41e8068e1ddd19bd4d1b",
|
|
["__init__.py", "nodes/image_nodes.py", "LICENSE"],
|
|
),
|
|
"load": (
|
|
"Kosinkadink/ComfyUI-VideoHelperSuite",
|
|
"8550981384301e9bc5bfea83e5c2c75258102593",
|
|
[
|
|
"__init__.py",
|
|
"videohelpersuite/load_video_nodes.py",
|
|
"videohelpersuite/nodes.py",
|
|
"videohelpersuite/utils.py",
|
|
"web/js/VHS.core.js",
|
|
"LICENSE",
|
|
],
|
|
),
|
|
"combine": (
|
|
"Kosinkadink/ComfyUI-VideoHelperSuite",
|
|
"0a75c7958fe320efcb052f1d9f8451fd20c730a8",
|
|
[
|
|
"__init__.py",
|
|
"videohelpersuite/nodes.py",
|
|
"videohelpersuite/utils.py",
|
|
"web/js/VHS.core.js",
|
|
"video_formats/h264-mp4.json",
|
|
"LICENSE",
|
|
],
|
|
),
|
|
}
|
|
|
|
|
|
def fetch(url):
|
|
with urllib.request.urlopen(
|
|
urllib.request.Request(url, headers={"User-Agent": "HEL-892-static-review"}), timeout=40
|
|
) as r:
|
|
return r.read()
|
|
|
|
|
|
def one(item):
|
|
key, (repo, commit, files) = item
|
|
tree = json.loads(fetch(f"https://api.github.com/repos/{repo}/git/trees/{commit}?recursive=1"))
|
|
assert tree["sha"] == commit and not tree["truncated"]
|
|
(REF / (key + "-tree.json")).write_text(json.dumps(tree, ensure_ascii=False, indent=2) + "\n")
|
|
blobs = {x["path"]: x["sha"] for x in tree["tree"]}
|
|
entries = []
|
|
for file in files:
|
|
url = f"https://raw.githubusercontent.com/{repo}/{commit}/{file}"
|
|
raw = fetch(url)
|
|
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
|
|
assert blob == blobs[file]
|
|
local = key + "__" + file.replace("/", "__")
|
|
(REF / local).write_bytes(raw)
|
|
entries.append(
|
|
dict(
|
|
id=key,
|
|
file=file,
|
|
local_file=local,
|
|
url=url,
|
|
commit=commit,
|
|
sha256=hashlib.sha256(raw).hexdigest(),
|
|
git_blob_sha1=blob,
|
|
)
|
|
)
|
|
return entries
|
|
|
|
|
|
def main():
|
|
REF.mkdir(exist_ok=True)
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
|
|
entries = [e for result in pool.map(one, PINS.items()) for e in result]
|
|
(REF / "sources.json").write_text(
|
|
json.dumps(dict(sources=entries), ensure_ascii=False, indent=2) + "\n"
|
|
)
|
|
print(f"PASS {len(entries)} Git text originals; 4 complete commits; metadata separate")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|