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] Make some improvements and fixes #1127

Merged
merged 22 commits into from
Dec 9, 2023

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Nov 19, 2023

This PR does multiple improvements and fixes to the YouTube service in the extractor.

  • It updates InnerTube clients' version and devices' OS version and model;
  • It improves payloads and URLs of InnerTube requests:
    • for every InnerTube request, a request object is set with the following properties:
      • internalExperimentFlags set to an empty array;
      • useSsl set to true;
      • lockedSafetyMode set to false.
    • for YouTube Music:
      • remove alt query parameter, as it is not used anymore by the website;
      • add prettyPrint query parameter with false value on YouTube Music search continuations.
  • It adds utcOffsetMinutes to all InnerTube payloads, previously only set on YouTube Music search continuations, which should make returned dates consistent between timezones and countries on which the extractor is ran;
  • It adds missing prettyPrint query parameter to some test InnerTube requests;
  • It switches to YouTube's new consent cookie;
  • It makes only extracting search results corresponding to a search type, as YouTube returns sometimes videos inside channel search results for example;
  • It supports new A/B tested like data (like in [YouTube] fix: handle new like count viewModel #1123 and [YT] Fix "Could not get like count" #1134, these changes have been written before both PRs have been opened) and avoid like count conversion from integer to long;
  • It removes Channels channel tab support, as this tab has been removed by YouTube;
  • It bypasses blocking crisis resources in search results, see https://support.google.com/youtube/answer/10726080?hl=en for more info on them;
  • It fixes all broken tests and updates mocks.

For more details, please look at commit messages and code changes.

Fixes #1133, fixes TeamNewPipe/NewPipe#10624.

@opusforlife2
Copy link
Collaborator

It switches to YouTube's new consent cookie;

This is still EU-only, right?

@opusforlife2
Copy link
Collaborator

In addition to the question above, will the users see any noticeable change with this, or is this all under-the-hood stuff?

@AudricV
Copy link
Member Author

AudricV commented Nov 30, 2023

This is still EU-only, right?

I don't think so, but I am not sure.

In addition to the question above, will the users see any noticeable change with this, or is this all under-the-hood stuff?

Some changes will be seen by users, as #1133 is fixed by this PR.

@opusforlife2
Copy link
Collaborator

I don't think so, but I am not sure.

Okay. Could you share a test build without the consent cookie? I can perform an action that needs it and see if it still works.

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! I reviewed the commits one by one and noticed only one suspect change.

I tested on an emulator and everything worked fine: app-debug.zip

As per the crisis resources change, shouldn't the extractor still return the warning as a meta info? E.g. see screenshot below. I will open a PR independent from this one if it's ok for you.

image

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.

Feel free to merge once you update the client versions! I opened #1135 in the meantime

For every InnerTube request:
- Always add a `request` object with the following properties:
  - "internalExperimentFlags" set to an empty array;
  - "useSsl" set to "true";
  - "lockedSafetyMode" set to "false".
- Use proper TODO comment to provide a way to enable restricted mode on every
request and add it on requests on which it wasn't present.

For YouTube Music:
- Remove alt query parameter, as it is not used anymore by the website;
- Add prettyPrint query parameter with false value on YouTube Music search
continuations.
This should make returned dates consistent between timezones and countries on
which the extractor is ran.

It was previously only set on YouTube Music search continuations.
…ube requests

This query parameter for which its value is set to false was not added to two
requests made in test classes of YoutubeMixPlaylistExtractorTest.

Also remove an unneeded ParsingException exception throwing declaration in a
test method.
Also move the documentation of the consent in its setter method in order to be
accessible publicly and improve it.
YouTube returns sometimes videos inside channel search results. As we only want
results corresponding to the type we requested, this commits makes
YoutubeSearchExtractor ignoring non-requested search results we get, using the
extractor LinkHandler's first content filter value.

Also remove an unneeded exception throwing declaration in
YoutubeSearchExtractor.
…rsion from integer to long

Also make minor improvements to current like data extraction and remove
previous like count data support, as it is not returned anymore.
This tab has been removed by YouTube.
These crisis resources are preventing search results to be returned. See
https://support.google.com/youtube/answer/10726080?hl=en for more info on them.

This commit changes search parameters to include the property allowing to show
search results.
Video's title and tags have been changed by its uploader, so they have to be
updated.

Also make some package-private constants private, as they are not used outside
of the class, and remove unneeded test overrides.
- Change CarouselHeader test channel to Sports system one, as the Coachella one
doesn't return this channel header anymore;
- Fix InteractiveTabbedHeader test by checking whether the test's channel
description is not empty instead of containing some words, as it is changing
frequently.
Replace the video used in this test class with another one publicly available
and update the corresponding expected test values.

The test class's mocks will be updated in a different commit.
…dMixTest

This commit fixes the testRelatedItems test method by:
- accepting consent in the test class, in order to extract mixes in
recommendations;
- removing assertion of a music mix inside the recommendations, as YouTube
doesn't seem to return such mixes anymore, at least for the video used in the
test class.
YouTube is rolling out or A/B testing a new date format returned inside player
responses, which are precise to the second instead of the day.

This commit makes the StreamExtractor tests use these more precise dates.
YouTube doesn't return anymore a suggestion for the query "algorythm", but does
for the query "on board ing" ("on boarding"). This search query is now used and
had to be URL-encoded.

URL encoding in the complete YoutubeSearchExtractorTest test class uses now
extractor's Util class instead of Java's URLDecoder class directly.
…tExtractorTest.LearningPlaylist

This change makes the method test whether there is no more items instead of
being disabled.
…st.CarouselHeader

The subscriber count is now lower than the expected count as some people
unsubscribed to the Sports system channel. The expected count has been so
lowered.
As search parameters to bypass crisis resources blocking search results have
been implemented, they need to be added to search tests, in order to pass
them.
This test only tests that search results are returned, when no content filters
are provided and crisis resources blocking search results should be returned.

Searches with blocking crisis resources and content filters should work too, as
the bypass has been implemented for them.
@AudricV AudricV merged commit 678c98f into TeamNewPipe:dev Dec 9, 2023
4 checks passed
@AudricV AudricV deleted the yt_improvements-and-fixes branch December 9, 2023 13:07
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.

[YouTube] Could not get like count (Fixed in code) YT: Could not get like count
3 participants