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 version and improve extraction of API key and client version of WEB client #890

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Aug 10, 2022

This PR fixes the replacement of the player response of a requested video by a one saying that This content is not available on this app, by adding the new required parameter, androidSdkVersion, for which the value sent is the one of the Android version we use on requests of the ANDROID client.

Detection of a player response redirection has been added on IOS and ANDROID clients to avoid this behavior in the future.

Client versions have been updated to their latest version and more parameters have been added on requests of the clients quoted above.

Extraction of InnerTube API key and client version of the WEB client from HTML page has been improved and requests to its JavaScript service worker and the one of the WEB_REMIX client have been removed, as they do not contain this information anymore (seems to be not the case everywhere, so these changes have been reverted). Extractions will now only use HTML pages.

Fixes TeamNewPipe/NewPipe#8713.

@AudricV AudricV added bug Issue is related to a bug youtube service, https://www.youtube.com/ labels Aug 10, 2022
@AudricV
Copy link
Member Author

AudricV commented Aug 10, 2022

Note: I didn't update the mocks, as I'd like to wait for #863 and #882 to be merged first, in order to not update multiple times mocks and/or get merge conflicts on them.

Do not run CI until these PRs are merged, it is unneeded as it will always fail due to missing updated mocks.

Reviews on the code changes can be made, even if this PR is marked as a draft.

@AudricV AudricV changed the title [YouTube] Update clients version and improve extraction of API key and client version of WEB and WEB_REMIX clients [YouTube] Update clients version and improve extraction of API key and client version of WEB client Aug 12, 2022
Common code in WEB client version HTML extraction has been deduplicated, usage of the Java 8 Stream API has been made and initial data fallback has been used as a last resort.
This means that the client version extraction from regexes will be used before this fallback, as it doesn't contain the full client version.
This can be used as a way to fingerprint the extractor, even if it seems to be not the case.
…lient

The iOS version can be got easily in fact, by looking at the What's New section of the App Store' app page.
Additional parameters have been added to the player requests of ANDROID and IOS
clients:

- for both clients: osName and osVersion: their respective values are:
  - for the ANDROID one: Android and 12;
  - for the IOS one: iOS and 15.6.0.19G71.
- for the ANDROID client: androidTargetSdkVersion, with the Android SDK version
  corresponding to the Android version used in the player requests of this
  client. This parameter is now required with this client to be sure to get a
  correct player response, otherwise, the one of a video saying that this
  content is not available in this app and to watch it with the latest version
  of YouTube can be returned instead;
- for the IOS client: deviceMake, with Apple as its value.

The iOS version sent in the IOS client player requests has been also updated to
the version 15.6 of the OS.

Finally, a comment about the requirement to use the signature timestamp from
the player JavaScript base file for HTML5 player requests on videos with
obfuscated URLs has been added and replaces a previous one which may be not
true.
If YouTube detect that requests come from a third party client, they may
replace the real player response by another one of a video saying that this
content is not available on this app and to watch it on the latest version of
YouTube. We can detect this by checking whether the video ID of the player
response returned is the same as the one requested by the extractor.
@AudricV AudricV force-pushed the yt-clients-update-improvements-and-extraction-fixes branch from 16b59af to 472f5d9 Compare August 12, 2022 17:21
@AudricV AudricV marked this pull request as ready for review August 12, 2022 17:21
@TobiGr TobiGr merged commit 76aad92 into TeamNewPipe:dev Aug 12, 2022
@AudricV AudricV deleted the yt-clients-update-improvements-and-extraction-fixes branch August 12, 2022 21:33
@sseodate

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug youtube service, https://www.youtube.com/
Projects
None yet
3 participants