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

Add parameters to get_video_info endpoint to fix 404 errors #938

Merged
merged 6 commits into from
Jun 26, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/info-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
2 changes: 2 additions & 0 deletions lib/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Collaborator

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... 😅

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually just searching the watch page gave me this
image
cver: 7.20190319 is over 1 year old...

Copy link
Contributor Author

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?

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

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

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

url.searchParams.set('eurl', VIDEO_EURL + id);
url.searchParams.set('ps', 'default');
url.searchParams.set('gl', 'US');
Expand Down