Skip to content

Commit 2c71524

Browse files
committed
更新版本V0.0.52
更新版本V0.0.52
1 parent 2570952 commit 2c71524

File tree

8 files changed

+71
-61
lines changed

8 files changed

+71
-61
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030

3131
> 最新更新:2025-04-28
3232
33-
> 0.0.51 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
33+
> 0.0.52 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
3434
>
3535
> 1. 新增功能:Lora详细界面内可以自定义自己的字段
3636
>
3737
> 2. 新增功能:在插件(非节点)UI内鼠标悬浮在Lora卡片上能显示Lora的基本信息
3838
>
3939
> 3. 修复了已知的BUG
4040
>
41+
> 4. Lora获取C站数据的时候可以一并获取封面了
42+
>
4143
4244
<details>
4345
<summary>点击查看往期更多更新内容</summary>

README_EN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ Due to limited personal time, the frequency of updating plug-ins will not be ver
2626

2727
> Last updated: 2025-04-28
2828
29-
> 0.0.51 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
29+
> 0.0.52 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
3030
>
3131
> 1. New feature: Within the Lora detailed interface, you can customize your own fields
3232
>
3333
> 2. New feature: When the mouse hoses over a Lora card within the plugin (non-node) UI, the basic information of Lora can be displayed
3434
>
3535
> 3. Fixed the known bugs
3636
>
37+
> 4. When Lora acquires data from C Station, it can also obtain the cover at the same time
38+
>
3739
3840
<details>
3941
<summary>Click here for more updates from the past</summary>

app/server/prompt_api/lora_info.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ async def get_model_info(file: str,
252252
if file_hash is not None:
253253
info_data['sha256'] = file_hash
254254
should_save = True
255+
256+
if len(info_data['images']) != 0 and file not in info_data['images'][0]['url']: # 未设置封面
257+
file_name = os.path.basename(file)
258+
url = next(filter(lambda x: x['type'] == 'image', info_data['images']), {}).get('url')
259+
download_image(url=url, filename=file_name, directory=os.path.dirname(file_path))
255260

256261
if should_save:
257262
if 'trainedWords' in info_data:
@@ -263,9 +268,32 @@ async def get_model_info(file: str,
263268

264269
# If we're saving, then the UI is likely waiting to see if the refreshed data is coming in.
265270
# await PromptServer.instance.send("weilin-refreshed-lora-info", {"data": info_data})
271+
266272

267273
return info_data
268274

275+
def download_image(url, filename, directory):
276+
try:
277+
# 安全处理文件名
278+
filename = filename.encode('utf-8', 'ignore').decode('utf-8')
279+
_, ext = os.path.splitext(url)
280+
filename, _ = os.path.splitext(filename)
281+
filepath = os.path.join(directory, f"{filename}{ext}")
282+
283+
try:
284+
resp = requests.get(url, stream=True)
285+
resp.raise_for_status()
286+
with open(filepath, 'wb') as f:
287+
for chunk in resp.iter_content(chunk_size=4096):
288+
f.write(chunk)
289+
except Exception as e:
290+
print(e)
291+
if os.path.exists(filepath):
292+
os.remove(filepath)
293+
294+
except Exception as e:
295+
print(f"文件名处理错误: {e}")
296+
269297

270298
def _merge_metadata(info_data: dict, data_meta: dict) -> bool:
271299
"""Returns true if data was saved."""

app/server/prompt_api/lora_networks.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from PIL import Image
55
import base64
66
from io import BytesIO
7-
import requests
87
import asyncio
98
import concurrent.futures
109
from tqdm import tqdm
@@ -26,27 +25,6 @@
2625
'metadata',
2726
]
2827

29-
def download_image(url, filename, directory):
30-
try:
31-
# 安全处理文件名
32-
filename = filename.encode('utf-8', 'ignore').decode('utf-8')
33-
_, ext = os.path.splitext(url)
34-
filename, _ = os.path.splitext(filename)
35-
filepath = os.path.join(directory, f"{filename}{ext}")
36-
37-
try:
38-
resp = requests.get(url, stream=True)
39-
resp.raise_for_status()
40-
with open(filepath, 'wb') as f:
41-
for chunk in resp.iter_content(chunk_size=4096):
42-
f.write(chunk)
43-
except Exception as e:
44-
print(e)
45-
if os.path.exists(filepath):
46-
os.remove(filepath)
47-
48-
except Exception as e:
49-
print(f"文件名处理错误: {e}")
5028

5129
def prepare_lora_item_data(item_path, auto_fetch=False):
5230
lora_path = folder_paths.get_full_path("loras", item_path)
@@ -65,9 +43,9 @@ def prepare_lora_item_data(item_path, auto_fetch=False):
6543
if auto_fetch:
6644
if len(info_data['images']) == 0: # 无数据
6745
info_data = asyncio.run(get_model_info(item_path, maybe_fetch_civitai=True, maybe_fetch_metadata=True, light=False))
68-
if len(info_data['images']) != 0 and item_path not in info_data['images'][0]['url']: # 未设置封面
69-
url = next(filter(lambda x: x['type'] == 'image', info_data['images']), {}).get('url')
70-
download_image(url=url, filename=file_name, directory=os.path.dirname(lora_path))
46+
# if len(info_data['images']) != 0 and item_path not in info_data['images'][0]['url']: # 未设置封面
47+
# url = next(filter(lambda x: x['type'] == 'image', info_data['images']), {}).get('url')
48+
# download_image(url=url, filename=file_name, directory=os.path.dirname(lora_path))
7149

7250
item = {
7351
"basename": item_path,

dist/javascript/main.entry.js

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/javascript/main.entry.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "weilin-comfyui-tools"
33
description = "让你在 ComfyUI 中快捷的使用提示词工具 Quickly use the prompt word tool in ComfyUI"
4-
version = "0.0.51"
4+
version = "0.0.52"
55
license = {file = "LICENSE"}
66
dependencies = []
77

0 commit comments

Comments
 (0)