-
Notifications
You must be signed in to change notification settings - Fork 811
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
Add parameters to get_video_info
endpoint to fix 404 errors
#938
Conversation
fixes 404 errors
this fixes the 404 error but it also seems to add about 5 second delay to a getInfo as well |
lib/info.js
Outdated
@@ -325,6 +325,8 @@ const VIDEO_EURL = 'https://youtube.googleapis.com/v/'; | |||
const getVideoInfoPage = async(id, options) => { | |||
const url = new URL(`https://${INFO_HOST}${INFO_PATH}`); | |||
url.searchParams.set('video_id', id); | |||
url.searchParams.set('c', 'TVHTML5'); | |||
url.searchParams.set('cver', '7.20190319'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to get this number from one of the prev. fetched pages? not a big fan of hard coding version numbers... 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I got the information from @zerodytrash. StackOverflow answers also suggest 6.20180913
for the version
https://stackoverflow.com/questions/67615278/get-video-info-youtube-endpoint-suddenly-returning-404-not-found
I tried it with other random numbers and strings and it seems to work too so I guess it only has to be set to something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change it to that value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting cver
to 2.20210621.02.00
seems to cause the issue all over again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok seems like to set cver
to 2.20210621.02.00
,you need to set c
to WEB
. but when i did this it still caused 404s sometimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now i am applying a local patch with c
set to TVHTML5
and cver
set to 6.20180913
get_video_info
endpointget_video_info
endpoint to fix 404 errors
@Jaques22 Hm I didn't notice any delay. Are you sure this is the culprit? |
@AlbinGrans Are those defined when you send the request without those parameters? Or is it just giving a 404 instead? |
I should note that I am using ytdl-core-discord which relies upon this so maybe a problem with that wrapper.
results definitely returns before the "start" log then it's about 5 seconds before the "end" log whereas before it was maybe 1-2s. |
New endpoint removes |
have heard of that befor in another context 🤔 so this might not be related to the 404's |
Yeh it's probably not related, just thought I'd add in case a faster alternative was doable but I guess we'll see if someone comes up with one |
The metadata seems to have changed with this. The duration no longer works. I might investigate this later today. If anyone has an idea let me know |
it perfectly works thank you. |
Hi, when will be this merged? |
@timbly5000 I personally use patch-package for now. You can apply the patch inside diff --git a/node_modules/ytdl-core/lib/info-extras.js b/node_modules/ytdl-core/lib/info-extras.js
index c806c9f..0cfe685 100644
--- a/node_modules/ytdl-core/lib/info-extras.js
+++ b/node_modules/ytdl-core/lib/info-extras.js
@@ -283,7 +283,7 @@ exports.cleanVideoDetails = (videoDetails, info) => {
// Use more reliable `lengthSeconds` from `playerMicroformatRenderer`.
videoDetails.lengthSeconds =
info.player_response.microformat &&
- info.player_response.microformat.playerMicroformatRenderer.lengthSeconds;
+ info.player_response.microformat.playerMicroformatRenderer.lengthSeconds || info.player_response.videoDetails.lengthSeconds;
return videoDetails;
};
diff --git a/node_modules/ytdl-core/lib/info.js b/node_modules/ytdl-core/lib/info.js
index 417f876..a2dd09a 100644
--- a/node_modules/ytdl-core/lib/info.js
+++ b/node_modules/ytdl-core/lib/info.js
@@ -325,6 +325,8 @@ const VIDEO_EURL = 'https://youtube.googleapis.com/v/';
const getVideoInfoPage = async(id, options) => {
const url = new URL(`https://${INFO_HOST}${INFO_PATH}`);
url.searchParams.set('video_id', id);
+ url.searchParams.set('c', 'TVHTML5');
+ url.searchParams.set('cver', '7.20190319');
url.searchParams.set('eurl', VIDEO_EURL + id);
url.searchParams.set('ps', 'default');
url.searchParams.set('gl', 'US'); |
Only @AlbinGrans Can you confirm that it's working now? |
Yep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change worked perfectly for me.
ok - thinking about giving this a pass, even though this breaks basically all videoDetails |
We can get the client version from the web and replace Like |
It's not fully working for me, still getting 404 Edit: yeah, definitively not working for me |
that sound's promising... didn't try that yet |
Are you sure the version numbers work like that? If so, we would need to pass the information from I did a little test (with #946 applied) and adding this at the bottom of const clientVersion = info.response.responseContext.serviceTrackingParams
.find(param => param.service === 'CSI').params
.find(param => param.key === 'cver').value;
const tvVersion = `7${clientVersion.substring(1)}`; (quick and dirty without any sanity checks) If this is going to be the way to go, how do we want to implement it? I thought about setting it to something like What should we use as a fallback value if |
thought about using besides that, i don't think that
is a real problem. If another option would be just caching it in a global variable... default value could be sth. like |
Thought I'd share this PR on lavaplayer sedmelluq/lavaplayer#640 Tested on my own branch and |
It also |
@TimeForANinja Thank you, that should do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at line 312 in info.js can you explain me what actually this code do ??
@TimeForANinja thanks for looking into this issue. I've got a large project that heavily relies on this library, do you have an ETA when a new release with these fixes will be published to NPM? Thanks, |
Waiting for some feedback from the other devs |
cherry-picked from distubejs@e13c2a9
🎉 This PR is included in version 4.8.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This fixes 404 errors.
See zerodytrash/Simple-YouTube-Age-Restriction-Bypass#18 (comment) for more information about this issue
Fixes #939