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

API: Fix URL for vtt subtitles #4221

Merged

Conversation

karelrooted
Copy link
Contributor

for fmt=vtt to work the fmt parameter in the original caption api url need to be replaced

@karelrooted karelrooted requested a review from a team as a code owner November 1, 2023 03:41
@karelrooted karelrooted requested review from SamantazFox and removed request for a team November 1, 2023 03:41
@absidue
Copy link
Contributor

absidue commented Nov 1, 2023

In all the API responses I've seen, YouTube doesn't include the fmt value by default.

As I'm guessing there is a reason why you opened this pull request, it's probably better to change this to proper query parameter handling, instead of a find and replace that won't always work.

@karelrooted
Copy link
Contributor Author

karelrooted commented Nov 1, 2023

In all the API responses I've seen, YouTube doesn't include the fmt value by default.

As I'm guessing there is a reason why you opened this pull request, it's probably better to change this to proper query parameter handling, instead of a find and replace that won't always work.

the YoutubeAPI::ClientType::Android client request response with fmt=srv3, I didn't dig deep into the code, but from the request recorded by the mitm proxy , there is two request for the videoid info, the second android one has fmt=srv3 and the second one is being used

for fmt=vtt to work the fmt parameter in the original caption api url need to be replaced
@karelrooted karelrooted force-pushed the fix/youtube-api-vtt-format-subtitle branch from 3c9da5b to c251c66 Compare November 14, 2023 05:16
Copy link
Member

@SamantazFox SamantazFox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good! If you could provide an example case where this code is required (= the relevant sample JSON response) that'd be perfect!

@karelrooted
Copy link
Contributor Author

karelrooted commented Nov 15, 2023

Code looks good! If you could provide an example case where this code is required (= the relevant sample JSON response) that'd be perfect

Code looks good! If you could provide an example case where this code is required (= the relevant sample JSON response) that'd be perfect!

fix in the commit subject might not be correctly word, invidious api always return correct vtt subtitle (the xml fallback check code is working), I have a local branch with bilingual subtitle support , when merging with newest upstream main branch , found the problem , so submit the PR

as json example , the following curl request shows append fmt=vtt to a already exist fmt=srv3 url did not work

append example (fmt=srv3&fmt=vtt , return xml)

curl 'https://www.youtube.com/api/timedtext?v=isY5MCWPi_0&ei=PW1UZb6tGNXM2roPxd2r2A4&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1700057005&sparams=ip,ipbits,expire,v,ei,opi,xoaf&signature=EB364571027A63836BB97ABE4EF93C73790B56F3.2B2D8D9E9143255F38CF415CBA9960AB619DED87&key=yt8&lang=en-US&fmt=srv3&tlang=&fmt=vtt' -H 'Host: www.youtube.com' -H 'User-Agent: Crystal' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-us,en;q=0.5' -H 'Cookie: ; CONSENT=PENDING+125' --compressed

replace example (fmt=vtt , return vtt)

curl 'https://www.youtube.com/api/timedtext?v=isY5MCWPi_0&ei=PW1UZb6tGNXM2roPxd2r2A4&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1700057005&sparams=ip,ipbits,expire,v,ei,opi,xoaf&signature=EB364571027A63836BB97ABE4EF93C73790B56F3.2B2D8D9E9143255F38CF415CBA9960AB619DED87&key=yt8&lang=en-US&fmt=vtt&tlang=' -H 'Host: www.youtube.com' -H 'User-Agent: Crystal' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-us,en;q=0.5' -H 'Cookie: ; CONSENT=PENDING+125' --compressed

by the way, as show in the above curl , invidious send api request to google server with user agent "Crystal", didn't this made google easily recognized the request is not from official client , should we set UA to a more commonly used official one?

@SamantazFox
Copy link
Member

by the way, as show in the above curl , invidious send api request to google server with user agent "Crystal", didn't this made google easily recognized the request is not from official client , should we set UA to a more commonly used official one?

This is a known bug, please see #4265

@SamantazFox SamantazFox added the need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something label Dec 6, 2023
Copy link

github-actions bot commented Mar 6, 2024

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

@github-actions github-actions bot added the stale label Mar 6, 2024
@github-actions github-actions bot closed this Apr 5, 2024
@SamantazFox SamantazFox reopened this Apr 20, 2024
@SamantazFox SamantazFox removed the stale label Apr 20, 2024
@SamantazFox SamantazFox added in-testing This feature has been deployed and is being tested ready and removed need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something in-testing This feature has been deployed and is being tested labels Jul 17, 2024
@SamantazFox SamantazFox changed the title fix youtube api vtt format subtitle API: Fix URL for vtt subtitles Jul 21, 2024
@SamantazFox SamantazFox merged commit 5a12005 into iv-org:master Jul 21, 2024
12 of 14 checks passed
@SamantazFox
Copy link
Member

Thanks for contributing to invidious :)

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

Successfully merging this pull request may close these issues.

3 participants