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

[YouTube] Update clients versions, restore access to some streams and more #1168

Merged
merged 11 commits into from Apr 20, 2024

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Apr 16, 2024

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

This PR updates YouTube hardcoded clients' versions to newer ones and removes usage of InnerTube API keys, as official clients do not use them anymore in all endpoints we use.

It also restores the availability some streams (itag 22 on musical videos, itag 139 (+DRC audio streams - used for stable audio feature on mobile apps), when iOS client fetch is not forced, itags 599 and 600) by using new player parameters found to workaround the integrity checks on the official Android app, which requires to pass DroidGuard's VM and to associate a visitor ID to InnerTube requests.

Finally, it adds the missing prettyPrint query parameter to mixes continuations and implements the new crisis meta info action data, while fixing YouTube tests and updating mocks on the fly.

⚠️ Breaking changes ⚠️

Due to the removal of the usage of InnerTube API keys, some methods in YoutubeParsingHelper which can be used by clients have been changed:

  • areHardcodedClientVersionAndKeyValid was renamed to isHardcodedClientVersionValid
  • getKey was removed, since there is no InnerTube API key anymore
  • resetClientVersionAndKey was renamed to resetClientVersion
  • isHardcodedYoutubeMusicKeyValid was renamed to isHardcodedYoutubeMusicClientVersionValid
  • getYoutubeMusicKey was renamed to getYoutubeMusicClientVersion and now just returns the version instead of (key, name, version), since there is no key anymore and the name is fixed ("67") and therefore hardcoded
  • other related methods which are not really meant to be used outside of the extractor

Closes #1112, as it is not relevant anymore, and fixes multiple issues which have been not reported as issues in the extractor/NewPipe's issue tracker.

The API keys are not used anymore by official clients in almost all cases
(still used by the Android app until it gets a configuration) for all requests
we made.

Clients and device OS versions have been bumped to their latest stable version
known.

Methods and fields related to API keys have been renamed or deleted if they're
no longer relevant.
YouTube disabled the effectiveness of the parameters which were used (the
player response we get redirects to another video), but new parameters which
work around Android's client integrity checks have been found.
The new action data can return multiple contact actions instead of only one,
which will be concatenated by a new line return.

This commit fixes tests of the CrisisResources test class of
YoutubeSearchExtractorTest.
YouTube now returns a Shorts tab for InteractiveTabbedHeader gaming channels,
which contains Shorts about the game of the topic channel but are not uploaded
on the game topic channel.

As this tab is already supported by the extractor, fetching a gaming topic
channel now returns a tab instead of none.

Channel name and channel URL of these Shorts needs to be set to null in a
separate commit, as Shorts on this tab do not have the topic channel as their
uploader.
@AudricV AudricV added bug enhancement youtube service, https://www.youtube.com/ labels Apr 16, 2024
@Theta-Dev
Copy link
Contributor

I would like to know more about this change. What is DroidGuard's VM? And how did you find out the new player parameters?

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thank you! Looks mostly good to me, I left just a few nitpicks

Copy link
Member

Choose a reason for hiding this comment

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

You renamed a lot of things in this class, maybe it would be better to choose a naming that is independent of implementation details? E.g. isHardcodedClientValid instead of isHardcodedClientVersionValid. No need to make changes right now unless you have a clear idea, though.

@AudricV
Copy link
Member Author

AudricV commented Apr 16, 2024

What is DroidGuard's VM?

See this presentation and reVanced threads about fixing the integrity checks which caused playback issues and our current failure to get streams from the ANDROID client in the extractor: https://www.romainthomas.fr/publication/22-sstic-blackhat-droidguard-safetynet/

And how did you find out the new player parameters?

See LuanRT/YouTube.js#624.

@AudricV AudricV marked this pull request as draft April 19, 2024 17:38
@Stypox Stypox marked this pull request as ready for review April 20, 2024 09:49
@Stypox Stypox merged commit fbe9e62 into TeamNewPipe:dev Apr 20, 2024
3 of 4 checks passed
@AudricV AudricV deleted the yt_upd-cver-rm-keys-and-do-fixes branch April 20, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Light" keys protection proposition with Base64 in the jar produced
3 participants