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

replicate headers and params made by yt apps #3290

Merged
merged 2 commits into from
Sep 15, 2022
Merged

Conversation

unixfox
Copy link
Member

@unixfox unixfox commented Aug 30, 2022

This PR tries to replicate all the necessary headers and parameters made by YouTube apps in order to look more like a real YouTube app.

This avoids being classified as "an outdated YouTube app" by YouTube servers like in #3230.

Closes #3230

@unixfox unixfox requested a review from SamantazFox August 30, 2022 14:23
@unixfox unixfox requested a review from a team as a code owner August 30, 2022 14:23
return if request.resource.starts_with? "/sorry/index"
request.headers["x-youtube-client-name"] ||= "1"
request.headers["x-youtube-client-version"] ||= "2.20200609"
# Preserve original cookies and add new YT consent cookie for EU servers
request.headers["cookie"] = "#{request.headers["cookie"]?}; CONSENT=YES+"
request.headers["Cookie"] = "#{request.headers["cookie"]?}; CONSENT=YES+"
Copy link
Member

Choose a reason for hiding this comment

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

When did we switch to "YES+" here!?

Copy link
Member

Choose a reason for hiding this comment

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

Uhhh, seems that we've always been using that: 739f610

Copy link
Member Author

Choose a reason for hiding this comment

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

For a long time, that's why I did create this PR back in the days: #2207

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically CONSENT=YES+ is only needed for the HTML pages. Like when fetching the captions.

Copy link
Member

Choose a reason for hiding this comment

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

I though it was only required for the "mixes" nowadays. I'm working on moving the captions to innertube, anyway...

Copy link
Member Author

@unixfox unixfox Sep 2, 2022

Choose a reason for hiding this comment

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

We could only send the CONSENT+YES cookie if we detect that the path doesn't start with /youtubei.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

We could even restrict more so that it's only sent for /mixes (or the associated innertube endpoint for mixes)

Copy link
Contributor

@absidue absidue Sep 16, 2022

Choose a reason for hiding this comment

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

@SamantazFox without the CONSENT=YES+ cookie EU IP addresses get redirected to the GDPR consent page, so it is definitely still required. AFAIK that also applies to requests to the InnerTube API.

Copy link
Member Author

@unixfox unixfox Sep 17, 2022

Choose a reason for hiding this comment

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

It doesn't apply to InnerTube API requests, you can test it by yourself, it works fine without this cookie.

It only applies to HTML pages, the InnerTube API is not an HTML page.

@unixfox
Copy link
Member Author

unixfox commented Sep 2, 2022

@SamantazFox I have replicated even more the requests made by a yt app, feel free to review again :D

@unixfox unixfox requested a review from SamantazFox September 2, 2022 19:19
@SamantazFox
Copy link
Member

Just in case: I wanted to add even more sppofing https://github.com/SamantazFox/invidious/tree/yt-api-improvements

@unixfox
Copy link
Member Author

unixfox commented Sep 2, 2022

Just in case: I wanted to add even more sppofing https://github.com/SamantazFox/invidious/tree/yt-api-improvements

Feel free to discontinue my PR in favor of your work. Do note about the useragents (IOS and android), devicemaker, devicemodel, ios osversion and x-youtube-client-name header.

EDIT: Just looked at the code and it's a very good idea to split things even more :). Good work.

@unixfox
Copy link
Member Author

unixfox commented Sep 6, 2022

@SamantazFox While we wait for you to finish your improvements, can we at least add the user agent required to solve the issue in #3230?

@SamantazFox
Copy link
Member

@unixfox yup, sure. Sorry for the delay :/

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.

Needs testing, though.

@unixfox
Copy link
Member Author

unixfox commented Sep 11, 2022

Needs testing, though.

We won't use your code from https://github.com/SamantazFox/invidious/tree/yt-api-improvements?

@SamantazFox
Copy link
Member

We won't use your code from https://github.com/SamantazFox/invidious/tree/yt-api-improvements?

Yes, but later. I don't have much time to work on it atm, so your solution will do in the meantime :)

@SamantazFox
Copy link
Member

Deployed on https://test.invidious.io

@unixfox unixfox added the need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something label Sep 11, 2022
@unixfox
Copy link
Member Author

unixfox commented Sep 15, 2022

After a few days of testing on yewtu.be. Everything seems fine.

Good to merge @SamantazFox?

@SamantazFox SamantazFox merged commit 221d472 into master Sep 15, 2022
@SamantazFox
Copy link
Member

@unixfox yep, done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Content not available in this app. upgrade to latest version of youtube.
3 participants