improve: badge
update scanner
This commit is contained in:
40
scanner.py
40
scanner.py
@@ -119,9 +119,9 @@ def get_git_urls_from_json(json_file):
|
||||
if node.get('install_type') == 'git-clone':
|
||||
files = node.get('files', [])
|
||||
if files:
|
||||
git_clone_files.append((files[0], node.get('title')))
|
||||
git_clone_files.append((files[0], node.get('title'), node.get('nodename_pattern')))
|
||||
|
||||
git_clone_files.append(("https://github.com/comfyanonymous/ComfyUI", "ComfyUI"))
|
||||
git_clone_files.append(("https://github.com/comfyanonymous/ComfyUI", "ComfyUI", None))
|
||||
|
||||
return git_clone_files
|
||||
|
||||
@@ -136,7 +136,7 @@ def get_py_urls_from_json(json_file):
|
||||
if node.get('install_type') == 'copy':
|
||||
files = node.get('files', [])
|
||||
if files:
|
||||
py_files.append((files[0],node.get('title')))
|
||||
py_files.append((files[0], node.get('title'), node.get('nodename_pattern')))
|
||||
|
||||
return py_files
|
||||
|
||||
@@ -171,25 +171,25 @@ def update_custom_nodes():
|
||||
|
||||
git_url_titles = get_git_urls_from_json('custom-node-list.json')
|
||||
|
||||
def process_git_url_title(url, title):
|
||||
def process_git_url_title(url, title, node_pattern):
|
||||
name = os.path.basename(url)
|
||||
if name.endswith(".git"):
|
||||
name = name[:-4]
|
||||
|
||||
node_info[name] = (url, title)
|
||||
node_info[name] = (url, title, node_pattern)
|
||||
clone_or_pull_git_repository(url)
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(10) as executor:
|
||||
for url, title in git_url_titles:
|
||||
executor.submit(process_git_url_title, url, title)
|
||||
for url, title, node_pattern in git_url_titles:
|
||||
executor.submit(process_git_url_title, url, title, node_pattern)
|
||||
|
||||
py_url_titles = get_py_urls_from_json('custom-node-list.json')
|
||||
py_url_titles_and_pattern = get_py_urls_from_json('custom-node-list.json')
|
||||
|
||||
def download_and_store_info(url_title):
|
||||
url, title = url_title
|
||||
def download_and_store_info(url_title_and_pattern):
|
||||
url, title, node_pattern = url_title_and_pattern
|
||||
name = os.path.basename(url)
|
||||
if name.endswith(".py"):
|
||||
node_info[name] = (url, title)
|
||||
node_info[name] = (url, title, node_pattern)
|
||||
|
||||
try:
|
||||
download_url(url, ".tmp")
|
||||
@@ -197,7 +197,7 @@ def update_custom_nodes():
|
||||
print(f"[ERROR] Cannot download '{url}'")
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(10) as executor:
|
||||
executor.map(download_and_store_info, py_url_titles)
|
||||
executor.map(download_and_store_info, py_url_titles_and_pattern)
|
||||
|
||||
return node_info
|
||||
|
||||
@@ -223,13 +223,15 @@ def gen_json(node_info):
|
||||
|
||||
dirname = os.path.basename(dirname)
|
||||
|
||||
if len(nodes) > 0:
|
||||
if len(nodes) > 0 or (dirname in node_info and node_info[dirname][2] is not None):
|
||||
nodes = list(nodes)
|
||||
nodes.sort()
|
||||
|
||||
if dirname in node_info:
|
||||
git_url, title = node_info[dirname]
|
||||
git_url, title, node_pattern = node_info[dirname]
|
||||
metadata['title_aux'] = title
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
data[git_url] = (nodes, metadata)
|
||||
else:
|
||||
print(f"WARN: {dirname} is removed from custom-node-list.json")
|
||||
@@ -237,15 +239,17 @@ def gen_json(node_info):
|
||||
for file in node_files:
|
||||
nodes, metadata = scan_in_file(file)
|
||||
|
||||
if len(nodes) > 0:
|
||||
if len(nodes) > 0 or (dirname in node_info and node_info[dirname][2] is not None):
|
||||
nodes = list(nodes)
|
||||
nodes.sort()
|
||||
|
||||
file = os.path.basename(file)
|
||||
|
||||
if file in node_info:
|
||||
url, title = node_info[file]
|
||||
url, title, node_pattern = node_info[file]
|
||||
metadata['title_aux'] = title
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
data[url] = (nodes, metadata)
|
||||
else:
|
||||
print(f"Missing info: {url}")
|
||||
@@ -256,7 +260,7 @@ def gen_json(node_info):
|
||||
for extension in extensions:
|
||||
node_list_json_path = os.path.join('.tmp', extension, 'node_list.json')
|
||||
if os.path.exists(node_list_json_path):
|
||||
git_url, title = node_info[extension]
|
||||
git_url, title, node_pattern = node_info[extension]
|
||||
|
||||
with open(node_list_json_path, 'r', encoding='utf-8') as f:
|
||||
node_list_json = json.load(f)
|
||||
@@ -272,6 +276,8 @@ def gen_json(node_info):
|
||||
nodes.add(x.strip())
|
||||
|
||||
metadata_in_url['title_aux'] = title
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
nodes = list(nodes)
|
||||
nodes.sort()
|
||||
data[git_url] = (nodes, metadata_in_url)
|
||||
|
||||
Reference in New Issue
Block a user