Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmatsushita opened this issue Sep 5, 2023 · 6 comments
Open

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

jmatsushita opened this issue Sep 5, 2023 · 6 comments

Comments

@jmatsushita
Copy link

jmatsushita commented Sep 5, 2023

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
Copy link
Author

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
Copy link
Author

And the sanity check:

# yt-dlp --version
2023.07.06

@jmatsushita
Copy link
Author

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
Copy link
Author

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 #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

def is_valid_youtube(link):
"""
Validate YouTube link is a valid one and also within the duration limit.
:param link: YouTube link to validate
"""
try:
info = get_meta_info(link)
if info['duration'] > settings.YOUTUBE_LENGTH_LIMIT:
raise ValidationError('Video length too long.')
except DownloadError:
raise ValidationError('Invalid YouTube link.')

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

@jmatsushita
Copy link
Author

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 🙏

@JeffreyCA
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants