spotify-downloader icon indicating copy to clipboard operation
spotify-downloader copied to clipboard

WebUI stopped working, Networking error?

Open FaNt4zMa opened this issue 1 year ago • 8 comments

System OS

Windows

Python Version

3.11 (CPython)

Install Source

pip / PyPi

Install version / commit hash

4.2.4

Expected Behavior vs Actual Behavior

Expected Behavior: Fetches the song and downloads it.

Actual Behavior: Doesn't fetch the song, unable to download.

Steps to reproduce - Ensure to include actual links!

  1. Launch WebUI (I use this specific command as I run SpotDL as a service: spotdl web --config --keep-alive --web-use-output-dir
  2. Paste a spotify song link and press enter

Traceback

C:\Users\Fantaz\Desktop>spotdl web
Updating web app

Files are stored in temporary directory and will be deleted after the program exits to save them to current directory
permanently enable the `web_use_output_dir` option
Starting web server

INFO:     Started server process [9452]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://192.168.2.55:8098 (Press CTRL+C to quit)
INFO:     192.168.2.55:50072 - "GET / HTTP/1.1" 200 OK
INFO:     192.168.2.55:50548 - "GET /search/https%3A//open.spotify.com/track/0OIed6UFpfT2nW4BffD7Js%3Fsi%3D60f0f18a5ad64757 HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\applications.py", line 292, in __call__
    await super().__call__(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
    raise exc
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
    raise exc
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in __call__
    raise e
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\routing.py", line 443, in handle
    await self.app(scope, receive, send)
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\staticfiles.py", line 103, in __call__
    response = await self.get_response(path, scope)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\utils\web.py", line 96, in get_response
    response = await super().get_response(path, scope)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\staticfiles.py", line 121, in get_response
    full_path, stat_result = await anyio.to_thread.run_sync(
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fantaz\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\staticfiles.py", line 177, in lookup_path
    return full_path, os.stat(full_path)
                      ^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Users\\Fantaz\\.spotdl\\dist\\search\\https:\\open.spotify.com\\track\\0OIed6UFpfT2nW4BffD7Js?si=60f0f18a5ad64757'
INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Removing sessions directories
INFO:     Application shutdown complete.
INFO:     Finished server process [9452]

C:\Users\Fantaz\Desktop>

Other details

I've had this setup working for about a year now, never had issues.. I dont know what could have changed on my system for it to stop working... I've allowed spotdl.exe in my firewall a long time ago and doing it again didnt fix it. Should I do Uvicorn instead/also? Using the .exe for the WebUI (version 4.2.0) was able to fetch song and download it. Could it be that the client ID/secret of my config need to be changed/updated? Thanks for any help! image image

FaNt4zMa avatar Mar 02 '24 21:03 FaNt4zMa

Hello, i just installed and got the same error, is there a solution? image

i also got this error when i was changing some setting on casaos

image

pinkgoatlol avatar Mar 10 '24 03:03 pinkgoatlol

Hi, I noticed the same error. I found in the "inspect/developer mode" that some calls were going to port 8800, instead of 8877. I am using the docker image, so instead of publishing the port 8877 to 8877, I published the port 8800 to 8877 and started working again.

Edit: When I run the docker image, I use the port 8877 "--port 8877".

cumal avatar Mar 30 '24 18:03 cumal

So I just updated and made a new config.. @cumal is definitly onto something because when using the default port 8800, I'm able to fetch and download songs from the WebUI, changing the port to anything else breaks it.. I don't know why that is the case, I've had it working on port 8098 for a very long time. Also, am I dumb or is there a way to run the WebUI in a docker container? Thanks

FaNt4zMa avatar May 11 '24 03:05 FaNt4zMa

I'm also running into the red bubble with 'Error: "Network Error"' when I try to perform a search via the web UI of my spotdl instance, which is running as a docker container behind a reverse proxy. If I redirect the exposed reverse proxy port 8800 to the normal 443 https port, then it all works fine. So it seems like the problem may be that the HTTP header must specify a destination port of 8800.

jspiers avatar Jun 13 '24 21:06 jspiers

Also, this problem seems to have been introduced as of v4.2.1 of the docker image (spotdl/spotify-downloader:v4.2.1), because I don't have this problem when reverting to v4.2.0.

Somewhere in here: https://github.com/spotDL/spotify-downloader/compare/v4.2.0...v4.2.1

EDIT: I've isolated the problem to this line: https://github.com/spotDL/spotify-downloader/blame/4f5d9b6e1f14a211cafaa936c66ad9b5d6a85e18/spotdl/console/web.py#L69

In v4.2.1, spotdl started using the master branch of spotdl/web-ui instead of the dev branch, and that's where the hard-coding of the port 8800 requirement appears to have been introduced. So I think the related web-ui bug that @snydergd identified above is the likely root of the problem.

jspiers avatar Jun 13 '24 21:06 jspiers

@jspiers Oh thats great! I knew something had changed... Would you mind adding me on Discord and explain/show me how to run the WebUI on Docker? I've been trying to move all my self-hosted programs to a Docker Linux env instead of Windows but couldn't figure how to install SpotDL (and still have access to the WebUI..) Thanks :)

Edit: nevermind I figured it out, now I just need to know how to edit the config.json file.. On Windows it was easy to find, no idea where it is with the docker image :(

FaNt4zMa avatar Jun 14 '24 02:06 FaNt4zMa

I've been trying to move all my self-hosted programs to a Docker Linux env instead of Windows but couldn't figure how to install SpotDL (and still have access to the WebUI..)

I do something similar myself, using docker compose for my self-hosted "homelab" setup to run spotdl behind a traefik v2 reverse proxy. My config might be a bit confusing with the multi-level file structure. I've seen other docker compose-based homelab setups that may be a bit cleaner.

jspiers avatar Jun 14 '24 15:06 jspiers

As a workaround for now, docker compose users can patch the docker image to use the dev branch of spotdl/web-ui (instead of master) by using an inline dockerfile which runs a sed regex replacement on the /spotdl/console/web.py file as follows:

services:
  spotdl:
    ...
    # comment out the docker image and use a build section instead
    # image: spotdl/spotify-downloader:v4.2.5
    build:
      dockerfile_inline: |
        FROM spotdl/spotify-downloader:v4.2.5
        RUN sed -i -e 's/web-ui\/tree\/master/web-ui\/tree\/dev/' /spotdl/console/web.py
   ...

Bring it up with docker compose up -d --build spotdl

jspiers avatar Jun 14 '24 18:06 jspiers

Looking into this issue. Version 4.2.6 will have two new options --web-gui-location and --web-gui-repo

xnetcat avatar Jul 21 '24 07:07 xnetcat

pushed an update to master, should be fixed :)

xnetcat avatar Jul 21 '24 10:07 xnetcat