invidious
invidious copied to clipboard
fix youtube api vtt format subtitle
for fmt=vtt to work the fmt parameter in the original caption api url need to be replaced
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.
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
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?
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
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.