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

fix(YouTube - Spoof video streams): Update client user-agent #4304

Conversation

LisoUseInAIKyrios
Copy link
Contributor

@LisoUseInAIKyrios LisoUseInAIKyrios commented Jan 16, 2025

  • Adjusts the client user agent to match the spoofed apps
  • Fixes wrong key name used for client id
  • Skips clients that require auth if the user is not logged in or is in incognito mode

@Figim

This comment was marked as outdated.

@LisoUseInAIKyrios

This comment was marked as resolved.

@LisoUseInAIKyrios LisoUseInAIKyrios force-pushed the fix/spoof_video_streams_user_agent branch from e03b53b to 32474c2 Compare January 16, 2025 16:54
@oSumAtrIX
Copy link
Member

I don't see the need to make it "more" authentic. It does not help in any realistic way. If YT wants to, it will detect invalid use of the API, regardless of how authentic we make it appear. If they don't, then there's no point to in the first place. I don't think the added code/complexity is worth this.

@LisoUseInAIKyrios
Copy link
Contributor Author

Some of the spoofed values such as the user agent have not been exactly correct until now.

The client id is also using the wrong key name (fixed with this PR).

Previously fixing the parameters also fixed some of the side effects, such as the last commit where the os name was missing and adding that restores AV1 for Android VR.

@oSumAtrIX
Copy link
Member

Only the fields are necessary which are also used by the other YT projects such as YT-DL afaik. The chipset is for example unnecessary.

@LisoUseInAIKyrios
Copy link
Contributor Author

LisoUseInAIKyrios commented Jan 17, 2025

I changed the user agent to an identical match of what is created in the spoofed apps (user-agent was found by inspecting the original app apks). Much more reliable then copy pasting what is randomly posted on the internet.

Also removed the more questionable fields such as chipset.

@LisoUseInAIKyrios LisoUseInAIKyrios force-pushed the fix/spoof_video_streams_user_agent branch from 13e1395 to 7f5ca5f Compare January 17, 2025 11:23
@LisoUseInAIKyrios LisoUseInAIKyrios changed the title fix(YouTube - Spoof video streams): Add more client parameters used by YouTube clients fix(YouTube - Spoof video streams): Update client user-agent Jan 17, 2025
@0xrxL
Copy link

0xrxL commented Jan 19, 2025

UPDATE: After further testing I can confirm that this PR leads to an improvement in buffering...despite being small.

Maybe some users will notice more marked improvements.

Copy link
Member

@oSumAtrIX oSumAtrIX left a comment

Choose a reason for hiding this comment

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

What's the reason for replacing a single user agent string parameter into multiple parameters?

@LisoUseInAIKyrios
Copy link
Contributor Author

LisoUseInAIKyrios commented Jan 19, 2025

The parameters are already present since clientVersion/make/model/etc is used in both the user agent and a request parameter of its own.

The user agent format for all android clients is 100% identical except for the values of course. So creating the user agent in the constructor removed the copy pasted data and it's only declared once.

@oSumAtrIX
Copy link
Member

It would avoid a lot of lines of code, such as the fields, the parameters, the complex string replacement and concatenation code for the user agent. It's probably better to replace all that in favor of a little copy pasta.

@0xrxL
Copy link

0xrxL commented Jan 20, 2025

Just use String.format.

@LisoUseInAIKyrios
Copy link
Contributor Author

String format would clean it up a little. Will change tomorrow.

@YT-Advanced
Copy link

We should add omitBotguardData into innertube request body (like this) to disable player attestation challenge and prevent GMS from throwing exception

@LisoUseInAIKyrios LisoUseInAIKyrios force-pushed the fix/spoof_video_streams_user_agent branch from 89ba839 to 9319103 Compare January 20, 2025 10:37
@LisoUseInAIKyrios
Copy link
Contributor Author

@YT-Advanced Is it confirmed that adding those parameters fixes the device botguard exception? I cannot reproduce the problem so I cannot verify.

@LisoUseInAIKyrios
Copy link
Contributor Author

Can make another PR for any other changes.

@LisoUseInAIKyrios LisoUseInAIKyrios merged commit 7917871 into ReVanced:dev Jan 20, 2025
1 check passed
@LisoUseInAIKyrios LisoUseInAIKyrios deleted the fix/spoof_video_streams_user_agent branch January 20, 2025 10:49
github-actions bot pushed a commit that referenced this pull request Jan 20, 2025
# [5.9.0-dev.4](v5.9.0-dev.3...v5.9.0-dev.4) (2025-01-20)

### Bug Fixes

* **YouTube - Spoof video streams:** Update client user-agent ([#4304](#4304)) ([7917871](7917871))
github-actions bot pushed a commit that referenced this pull request Jan 20, 2025
# [5.9.0](v5.8.1...v5.9.0) (2025-01-20)

### Bug Fixes

* **YouTube - Spoof video streams:** Resolve playback issues after changing from cellular to wifi ([#4277](#4277)) ([e93e1c8](e93e1c8))
* **YouTube - Spoof video streams:** Update client user-agent ([#4304](#4304)) ([7917871](7917871))

### Features

* **YouTube - Hide feed components:** Handle new type of surveys ([#4295](#4295)) ([c770e03](c770e03))
* **YouTube - Playback speed:** Add option to change 2x tap and hold speed ([#4307](#4307)) ([02fb26e](02fb26e))
* **YouTube - Settings:** Add option to use new Cairo settings menus ([#4305](#4305)) ([7b8a2a2](7b8a2a2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants