rgthree / rgthree-comfy

Making ComfyUI more comfortable!
MIT License
1.19k stars 84 forks source link

[bug] civitai problem with power lora loader (rg3) node #294

Closed ytoaa closed 3 months ago

ytoaa commented 3 months ago

Error handling request Traceback (most recent call last): File "Q:\ComfyUI\venv\lib\site-packages\aiohttp\web_protocol.py", line 452, in _handle_request resp = await request_handler(request) File "Q:\ComfyUI\venv\lib\site-packages\aiohttp\web_app.py", line 543, in _handle resp = await handler(request) File "Q:\ComfyUI\venv\lib\site-packages\aiohttp\web_middlewares.py", line 114, in impl return await handler(request) File "Q:\ComfyUI\server.py", line 45, in cache_control response: web.Response = await handler(request) File "Q:\ComfyUI\server.py", line 57, in cors_middleware response = await handler(request) File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\rgthree_server.py", line 138, in refresh_get_loras_info api_response = await get_loras_info_response(request, File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\rgthree_server.py", line 150, in get_loras_info_response info_data = await get_model_info(lora_file, File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\utils_info.py", line 116, in get_model_info data_civitai = _get_model_civitai_data(file, File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\utils_info.py", line 308, in _get_model_civitai_data file_data = read_userdata_json(json_file_path) File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\utils_userdata.py", line 35, in read_userdata_json return load_json_file(file_path) File "Q:\ComfyUI\custom_nodes\rgthree-comfy\py\utils.py", line 88, in load_json_file return json.loads(config) File "C:\Users\gas\AppData\Local\Programs\Python\Python310\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\gas\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\gas\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid control character at: line 32 column 27 (char 1127)

https://civitai.com/models/538854/maka-albarn-soul-eater https://civitai.com/models/308865/hikari-fellatio-invitationafter-fellatio-concept-lora

In civitai, a special character "//" is included in the title, causing an error.

ytoaa commented 3 months ago

def load_json_file(file: str, default=None): """Reads a json file and returns the json dict, stripping out "//" comments first.""" if path_exists(file): with open(file, 'r', encoding='UTF-8') as file: config = file.read() config = re.sub(r'"model"\s:\s{.?"name"\s:\s"([^"])//([^"])"', r'"model": {\n "name": "\1//\2"', config, flags=re.DOTALL) config = re.sub(r"(?:^|\s)//.", "", config, flags=re.MULTILINE)

with open("test.json", "w", encoding='UTF-8') as f:

#  json.dump(config, f, indent=4)
return json.loads(config)

return default

First of all, I temporarily wrote how to modify the text as above.