BlafKing / sd-civitai-browser-plus

Extension to access CivitAI via WebUI: download, delete, scan for updates, list installed models, assign tags, and boost downloads with multi-threading.
GNU Affero General Public License v3.0
282 stars 43 forks source link

[Bug]: Search does not work after fresh install #284

Open nanojin opened 1 month ago

nanojin commented 1 month ago

Describe the bug.

Cannot use the browser interface at all.

Any queries result in error screens and the following output.

image image

Steps to reproduce the problem.

  1. Install Automatic1111 webui and update
  2. After launching webui, go to Extensions, install CivitAI Browser+ and update
  3. Attempt to search

Expected behavior

Perform the search and display the results.

System info

Console logs

WARNING:fake_useragent:Error occurred during loading data. Trying to use cache server https://fake-useragent.herokuapp.com/browsers/0.1.11██████| 20/20 [00:05<00:00,  3.99it/s]
Traceback (most recent call last):
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 99, in get_browsers
    html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range
Traceback (most recent call last):
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 99, in get_browsers
    html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 64, in get
    with contextlib.closing(urlopen(
  File "urllib\request.py", line 216, in urlopen
  File "urllib\request.py", line 525, in open
  File "urllib\request.py", line 634, in http_response
  File "urllib\request.py", line 563, in error
  File "urllib\request.py", line 496, in _call_chain
  File "urllib\request.py", line 643, in http_error_default
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\mount\ai\webui\a1111\system\python\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "C:\mount\ai\webui\a1111\webui\extensions\sd-civitai-browser-plus\scripts\civitai_api.py", line 368, in initial_model_page
    gl.json_data = request_civit_api(api_url)
  File "C:\mount\ai\webui\a1111\webui\extensions\sd-civitai-browser-plus\scripts\civitai_api.py", line 1188, in request_civit_api
    headers = get_headers()
  File "C:\mount\ai\webui\a1111\webui\extensions\sd-civitai-browser-plus\scripts\civitai_api.py", line 1171, in get_headers
    user_agent = UserAgent().chrome
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\fake.py", line 69, in __init__
    self.load()
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\fake.py", line 75, in load
    self.data = load_cached(
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 250, in load_cached
    update(path, use_cache_server=use_cache_server, verify_ssl=verify_ssl)
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 245, in update
    write(path, load(use_cache_server=use_cache_server, verify_ssl=verify_ssl))
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 187, in load
    ret = json.loads(get(
  File "C:\Users\VTX\AppData\Roaming\Python\Python310\site-packages\fake_useragent\utils.py", line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

Additional information

It may be possible that CivitAI has changed something on their side. They have recently switched to a monetization model which makes access to their resources slightly more scarce, such as vaulted models which are no longer available for download.

As a control, I installed a second resource browser named CivBrowser (last updated 16-May-2024), which can browse CivitAI without any issues.

BlafKing commented 1 month ago

Thanks for reporting!

Looks like the python library called "fake user agent" is causing this issue, not exactly sure why but I'll make a hotfix for it shortly, thanks again for letting me know!

And apologies for the lack of updates lately, been really busy with my new job :')

BlafKing commented 1 month ago

Latest hotfix removes fake_useragent from this extension, please have a look if the extension now works again! :)