155 lines
5.1 KiB
Python
155 lines
5.1 KiB
Python
"""Fetch only pinned upstream text; never import upstream code."""
|
||
|
||
import concurrent.futures
|
||
import datetime
|
||
import hashlib
|
||
import json
|
||
import urllib.request
|
||
from pathlib import Path
|
||
|
||
OUT = Path(__file__).resolve().parents[1] / "tts-reference"
|
||
SPECS = {
|
||
"core": (
|
||
"Comfy-Org/ComfyUI",
|
||
"b874bd2b8c324d58cfc37bff0754dd16815a8f3c",
|
||
[
|
||
"comfy_extras/nodes_audio.py",
|
||
"comfy_extras/nodes_preview_any.py",
|
||
"comfy_api/latest/_ui.py",
|
||
"LICENSE",
|
||
"folder_paths.py",
|
||
],
|
||
),
|
||
"cr": (
|
||
"Suzie1/ComfyUI_Comfyroll_CustomNodes",
|
||
"d78b780ae43fcf8c6b7c6505e6ffb4584281ceca",
|
||
["__init__.py", "node_mappings.py", "nodes/nodes_core.py"],
|
||
),
|
||
"loader": (
|
||
"AICoderTudou/ComfyUI-TD-Qwen3TTS",
|
||
"90b117502f237dd008c541372b72935d93ae894c",
|
||
["__init__.py", "nodes.py", "LICENSE"],
|
||
),
|
||
"dialog": (
|
||
"AICoderTudou/ComfyUI-TD-Qwen3TTS",
|
||
"0c20c6b9ac22ecc4b5525de651fca0776a382dd3",
|
||
["__init__.py", "nodes.py", "LICENSE", "js/batch_speaker.js", "js/multi_dialog.js"],
|
||
),
|
||
"layer": (
|
||
"chflame163/ComfyUI_LayerStyle",
|
||
"d94bef1ee5ed3656f5ff1bb2830a4ffd94f40935",
|
||
["__init__.py", "py/purge_vram.py", "py/imagefunc.py", "LICENSE"],
|
||
),
|
||
}
|
||
|
||
|
||
def get(url):
|
||
with urllib.request.urlopen(url, timeout=40) as r:
|
||
return r.read()
|
||
|
||
|
||
def fetch(spec):
|
||
key, (repo, rev, files) = spec
|
||
base = f"https://api.github.com/repos/{repo}/git/"
|
||
tree = get(base + f"trees/{rev}?recursive=1")
|
||
t = json.loads(tree)
|
||
assert not t["truncated"]
|
||
(OUT / (key + "-tree.json")).write_bytes(tree)
|
||
commit = get(base + f"commits/{rev}")
|
||
(OUT / (key + "-commit.json")).write_bytes(commit)
|
||
rows = []
|
||
for f in files:
|
||
url = f"https://raw.githubusercontent.com/{repo}/{rev}/{f}"
|
||
raw = get(url)
|
||
blob = next(e["sha"] for e in t["tree"] if e["path"] == f)
|
||
assert hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == blob
|
||
name = key + "__" + f.replace("/", "__")
|
||
(OUT / name).write_bytes(raw)
|
||
rows.append(
|
||
dict(
|
||
id=key,
|
||
repo=repo,
|
||
file=f,
|
||
local_file=name,
|
||
commit=rev,
|
||
tree=json.loads(commit)["tree"]["sha"],
|
||
url=url,
|
||
sha256=hashlib.sha256(raw).hexdigest(),
|
||
git_blob_sha1=blob,
|
||
fetched_at=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||
license_file="原Git树无LICENSE,许可文本未知" if key == "cr" else key + "__LICENSE",
|
||
applicability="源声明准确提交;发布包/目标安装绑定未知",
|
||
transport="GitHub pinned raw text; blob verified",
|
||
)
|
||
)
|
||
return rows
|
||
|
||
|
||
def impact():
|
||
import io
|
||
import zipfile
|
||
|
||
repo = "ltdrdata/ComfyUI-Impact-Pack"
|
||
url = "https://api.comfy.org/nodes/comfyui-impact-pack/versions/8.28.2"
|
||
raw = get(url)
|
||
registry = json.loads(raw)
|
||
(OUT / "impact-registry.json").write_bytes(raw)
|
||
url = registry["downloadUrl"]
|
||
raw = get(url)
|
||
(OUT / "impact-source.zip").write_bytes(raw)
|
||
sha = hashlib.sha256(raw).hexdigest()
|
||
rows = []
|
||
with zipfile.ZipFile(io.BytesIO(raw)) as z:
|
||
members = [
|
||
dict(path=i.filename, size=i.file_size, sha256=hashlib.sha256(z.read(i)).hexdigest())
|
||
for i in z.infolist()
|
||
if not i.is_dir()
|
||
]
|
||
for file in [
|
||
"__init__.py",
|
||
"modules/impact/logics.py",
|
||
"modules/impact/util_nodes.py",
|
||
"modules/impact/core.py",
|
||
"js/impact-logics.js",
|
||
"LICENSE.txt",
|
||
"pyproject.toml",
|
||
]:
|
||
if file not in z.namelist():
|
||
continue
|
||
data = z.read(file)
|
||
name = "impact__" + file.replace("/", "__")
|
||
(OUT / name).write_bytes(data)
|
||
rows.append(
|
||
dict(
|
||
id="impact",
|
||
repo=repo,
|
||
file=file,
|
||
local_file=name,
|
||
url=url,
|
||
commit="发布包SHA256:" + sha,
|
||
package_sha256=sha,
|
||
git_commit_binding="unknown",
|
||
sha256=hashlib.sha256(data).hexdigest(),
|
||
fetched_at=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||
license_file="impact__LICENSE.txt",
|
||
tag="8.28.2",
|
||
applicability="准确发布8.28.2;Git提交及目标绑定未知",
|
||
)
|
||
)
|
||
(OUT / "impact-members.json").write_text(json.dumps(members, indent=2) + "\n")
|
||
return rows
|
||
|
||
|
||
def main():
|
||
OUT.mkdir(parents=True, exist_ok=True)
|
||
with concurrent.futures.ThreadPoolExecutor(max_workers=3) as ex:
|
||
rows = sum(ex.map(fetch, SPECS.items()), [])
|
||
rows += impact()
|
||
(OUT / "sources.json").write_text(
|
||
json.dumps(dict(sources=rows), ensure_ascii=False, indent=2) + "\n"
|
||
)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|