JeffreyCA / spleeter-web

Self-hostable web app for isolating the vocal, accompaniment, bass, and drums of any song. Supports Spleeter, D3Net, Demucs, Tasnet, X-UMX. Built with React and Django.
https://jeffreyca.github.io/spleeter-web/
MIT License
422 stars 78 forks source link

Bad Request: /api/source-file/youtube/ #764

Open jmatsushita opened 1 year ago

jmatsushita commented 1 year ago

When inputting a youtube link in the upload modal, the spinner resolves as a cross and it's not possible to click next, and the following logs are emitted:

image

spleeter-web-api-1          | [youtube] Extracting URL: https://www.youtube.com/watch?v=XutKfAL7wx8
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading webpage
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading ios player API JSON
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading android player API JSON
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading m3u8 information
spleeter-web-api-1          | [youtube] Extracting URL: https://www.youtube.com/watch?v=XutKfAL7wx8
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading webpage
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading ios player API JSON
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading android player API JSON
spleeter-web-api-1          | [youtube] XutKfAL7wx8: Downloading m3u8 information
spleeter-web-api-1          | 2023-09-05 10:33:09,551 [django.request][WARNING]: Bad Request: /api/source-file/youtube/

I'm running the latest gpu containers:

docker compose images
Container                    Repository                        Tag                 Image Id            Size
spleeter-web-api-1           jeffreyca/spleeter-web-backend    latest-gpu          60f9e67adb8a        17.8GB
spleeter-web-celery-fast-1   jeffreyca/spleeter-web-backend    latest-gpu          60f9e67adb8a        17.8GB
spleeter-web-celery-slow-1   jeffreyca/spleeter-web-backend    latest-gpu          60f9e67adb8a        17.8GB
spleeter-web-frontend-1      jeffreyca/spleeter-web-frontend   latest              84aed5457312        1.26GB
spleeter-web-nginx-1         jeffreyca/spleeter-web-nginx      latest              4341cde7573e        465MB
spleeter-web-redis-1         redis                             6.0-buster          2ae0b0b508a3        104MB
jmatsushita commented 1 year ago

Running yt-dlp directly from within the container works

▶  docker compose exec api bash
root@04d350116702:/webapp# yt-dlp https://www.youtube.com/watch?v=XutKfAL7wx8
[youtube] Extracting URL: https://www.youtube.com/watch?v=XutKfAL7wx8
[youtube] XutKfAL7wx8: Downloading webpage
[youtube] XutKfAL7wx8: Downloading ios player API JSON
[youtube] XutKfAL7wx8: Downloading android player API JSON
[youtube] XutKfAL7wx8: Downloading m3u8 information
[info] XutKfAL7wx8: Downloading 1 format(s): 616+251
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 48
[download] Destination: Khruangbin - August 10 [XutKfAL7wx8].f616.mp4
[download] 100% of   26.64MiB in 00:00:11 at 2.41MiB/s
[download] Destination: Khruangbin - August 10 [XutKfAL7wx8].f251.webm
[download] 100% of    4.39MiB in 00:00:00 at 9.22MiB/s
[Merger] Merging formats into "Khruangbin - August 10 [XutKfAL7wx8].webm"
Deleting original file Khruangbin - August 10 [XutKfAL7wx8].f251.webm (pass -k to keep)
Deleting original file Khruangbin - August 10 [XutKfAL7wx8].f616.mp4 (pass -k to keep)
root@04d350116702:/webapp# 
jmatsushita commented 1 year ago

And the sanity check:

# yt-dlp --version
2023.07.06
jmatsushita commented 1 year ago

I see I missed some relevant logs:

spleeter-web-nginx-1        | 100.70.7.21 - - [05/Sep/2023:10:56:45 +0000] "GET /api/source-file/youtube/?link=https:%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXutKfAL7wx8 HTTP/1.1" 400 69 "http://100.70.7.21/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" "-"
spleeter-web-api-1          | 2023-09-05 10:56:45,115 [django.request][WARNING]: Bad Request: /api/source-file/youtube/
jmatsushita commented 1 year ago

I used the chrome inspector and see that there is a response for the call to http://x.x.x.x/api/source-file/youtube/?link=https:%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXutKfAL7wx

{"status": "error", "errors": ["Invalid YouTube link."]}

That seems to be the same error than this issue https://github.com/JeffreyCA/spleeter-web/issues/519 however note that the error doesn't display on the frontend unlike the first screenshot on that issue.

Seems the error is thrown here https://github.com/JeffreyCA/spleeter-web/blob/df53bf3eb0fd543b4d57ee0e57267a546aa78652/api/validators.py#L45-L56

I'll try and log the message for that DownloadError exception.

jmatsushita commented 1 year ago

Ah ha! I removed the outer try/except block and see this error being raised

{"status": "duplicate", "id": "63919df5-9081-4a5b-af26-20dd9551255a"}

It makes sense as there was a previous attempt that failed in the database. And indeed if I remove that previous entry, everything works!

I'll keep the ticket open as a reminder that maybe error reporting could be improved here (and seems to also not work as it did previously compared to the linked issue's screenshot) by adding extra information from the DownloadError exception to the raised ValidationError.

Thanks again for the great project :pray:

JeffreyCA commented 1 year ago

Thanks for the detailed issue! Just to clarify, did you just delete the track from the UI and reimported the link? Or did you have to manually delete it from the database?