[YouTube] Fix extraction of the Trending kiosk with the new data model returned #920
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I didn't test the changes on NewPipe but tested multiple times the changes using the
YoutubeTrendingKioskInfoTest
test classThis pull request adds support of the new data model returned for trends, which is A/B tested or deployed by YouTube.
This new structure allow us to filter easily
Trending shorts
andRecently trending
sections.On the previous one, this
Recently trending
section is now filtered (theTrending shorts
one uses a different structure, which so was already not extracted), by checking whether sections have a title, which isn't the case for normal trends contrary to the other ones.This makes that the extractor returns now only the real 50
Now
YouTube trends, with both data models returned by YouTube.Elements inside arrays are now extracted dynamically instead of only the ones of the first index, using Java 8's Stream API.
Note: The
getInitialPage()
method ofYoutubeTrendingExtractor
can now throw aParsingException
if no selected tab (corresponding to the one of the trends type extracted) has been found.Finally, the licence header of this class has been moved to the top of the file and updated.
Fixes #899, fixes TeamNewPipe/NewPipe#8835.