From cb82855f0f7e562182f8404871cf4fbc374f4b7f Mon Sep 17 00:00:00 2001 From: AhBumm Date: Wed, 22 Apr 2026 10:59:47 +0800 Subject: [PATCH] url extract node remove duplicates content --- nodes4tuzi.py | 27 ++++++++++++++------------- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/nodes4tuzi.py b/nodes4tuzi.py index 5ad239e..c91b9b6 100644 --- a/nodes4tuzi.py +++ b/nodes4tuzi.py @@ -525,13 +525,16 @@ class RegTuziChatResponse: ) all_urls.extend(base64_urls) - # 3. Deduplicate URLs while preserving order - unique_urls = [] - seen = set() + # 3. Deduplicate by filename, keeping the last occurrence + filename_to_url = {} for url in all_urls: - if url not in seen: - unique_urls.append(url) - seen.add(url) + if url.startswith('data:'): + # base64 data URIs: use the full string as key + filename_to_url[url] = url + else: + fname = urlparse(url).path.rsplit('/', 1)[-1] + filename_to_url[fname] = url + unique_urls = list(dict.fromkeys(filename_to_url.values())) out_str = ",".join(unique_urls) @@ -557,15 +560,13 @@ class RegTuziChatResponse: ) video_urls.extend(regex_video_urls) - # 2. Deduplicate and get the last URL - unique_urls = [] - seen = set() + # 2. Deduplicate by filename, keeping the last occurrence + filename_to_url = {} for url in video_urls: - if url not in seen: - unique_urls.append(url) - seen.add(url) + fname = urlparse(url).path.rsplit('/', 1)[-1] + filename_to_url[fname] = url + unique_urls = list(dict.fromkeys(filename_to_url.values())) out_str = unique_urls[-1] if unique_urls else "" return (out_str,) - diff --git a/pyproject.toml b/pyproject.toml index c4a0997..dce3c8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_billbum_api_nodes" description = "New Support Seedance2.0 api Now!!! API call node for Third-party platforms both official and local. Support VLMs LLMs Dalle3 Flux-Pro(Support kontext, banana etc... now!! and new Support gpt-image-1!!). And some little tools: img to b64 url, b64 url to img, b64 url to b64 data, reg text to word and ',' only, etc." -version = "1.2.3" +version = "1.2.4" license = {file = "LICENSE"} dependencies = ["tenacity", "openai", "pillow", "requests", "numpy", "tiktoken", "urlextract"]