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] Workaround Shorts UI for playlists by using a continuation for initial items #1104

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Sep 17, 2023

YouTube don't return currently a continuation, if applicable, for the Shorts UI in playlists, restricting access to the 100th first items. The reel items returned don't give also upload date, uploader info and precise view count.

Using a continuation which requests the first page of the playlist allows currently to get access to continuations, if applicable, and also standard video elements instead of Shorts ones, making extraction of upload date, uploader info and precise view count again possible.

This continuation is only requested and used when the data structure should be the one of the Shorts UI.

A fallback to the standard response is made in the cases where fetching or parsing the continuation response fails, or when no stream items are extracted.

This change required to:

  • add a protocol buffer definition file for which its structure is based on reverse engineering of playlists continuations sent by WEB InnerTube client, received from InnerTube responses;
  • add a dependency on Protobuf Java Lite;
  • generate Java classes from the definition file with the protoc version corresponding to the one of the Protobuf Java Lite dependency used (see https://protobuf.dev/support/version-support/ for more details); they are excluded from Checkstyle checks as they do not follow our style rules at all;
  • add a dependency on Apache Commons Codec, as Java's Base64 class desugaring for Android is not released yet.

As a result of this change, testMoreRelatedItems method of YoutubePlaylistExtractorTest.ShortsUI test class has been enabled, as we now get continuations for shorts playlists with more than 100 items and mocks of this test class had to be updated.

@AudricV AudricV added enhancement youtube service, https://www.youtube.com/ labels Sep 17, 2023
…for initial items

YouTube don't return currently a continuation, if applicable, for the Shorts UI
in playlists, restricting access to the 100th first items. The reel items
returned don't give also upload date, uploader info and precise view count.

Using a continuation which requests the first page of the playlist allows
currently to get access to continuations, if applicable, and also standard
video elements instead of Shorts ones, making extraction of upload date,
uploader info and precise view count again possible.

This continuation is only requested and used when the data structure should be
the one of the Shorts UI.

A fallback to the standard response is made in the cases where fetching or
parsing the continuation response fails, or when no stream items are extracted.

This change required to:
- add a protocol buffer definition file for which its structure is based on
reverse engineering of playlists continuations sent by WEB InnerTube client,
received from InnerTube responses;
- add a dependency on Protobuf Java Lite;
- generate Java classes from the definition file with the protoc version
corresponding to the one of the Protobuf Java Lite dependency used (see
https://protobuf.dev/support/version-support/ for more details); they are
excluded from Checkstyle checks as they do not follow our style rules at all;
- add a dependency on Apache Commons Codec, as Java's Base64 class desugaring
for Android is not released yet.
…dItems

As continuations are now again available for playlists with Shorts UI, more
items' tests can be enabled.
@AudricV AudricV force-pushed the yt_continuations-playlists-shorts-ui branch from bccde47 to 2e3f6b4 Compare September 22, 2023 15:10
@AudricV AudricV marked this pull request as draft October 6, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant