Skip to content

perf(youtube): ask InnerTube only for the parts of next that are read - #127

Open
Priveetee wants to merge 1 commit into
InfinityLoop1308:mainfrom
TypeType-Video:perf/youtube-innertube-fields
Open

Priveetee wants to merge 1 commit into
InfinityLoop1308:mainfrom
TypeType-Video:perf/youtube-innertube-fields

Conversation

@Priveetee

Copy link
Copy Markdown
Contributor

InnerTube honours the fields parameter of Google APIs, so a response can be limited to the keys we actually read.

Two uses here:

  • the watch page next only reads contents and engagementPanels. Asking for those drops the top bar, the player overlays and the tracking data: 56 kB to 40 kB compressed.
  • the comments extractor asks the same next again only to find its continuation token. It now asks for the main column alone, without the related videos: 56 kB to 6 kB.

If the server ever ignores the parameter it answers with the whole response, which is parsed like before.

The official web client doesn't send fields, so these requests don't look exactly like its own. I only used it on next, not on player.

I also tried it on the comments continuation (no gain, the response is already only payload) and tried next with other clients (MWEB is half the size but needs another parser, ANDROID and IOS answer 2.4 MB, none is faster).

Validation:

  • ./gradlew :extractor:build passes.
  • Emulator: comments, replies count, related videos, likes and views show up as before. 65 kB less per video opened.

InnerTube honours the fields parameter of Google APIs. The watch page
response is now limited to its contents and engagement panels, which
drops the top bar, the player overlays and the tracking data, about a
third of it.

The comments extractor requested the same page again only to find its
continuation token: it now asks for the main column alone, without the
related videos, about ten times smaller.

A server that ignores the parameter answers with the whole response,
which is parsed as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant