Phase 3 — InnerTube + itag

Port the YT client matrix + request envelope + itag lookup table.

src/youtube/
  * constants.rs       — ClientsConstants.java verbatim. All six live
                         clients (WEB, WEB_EMBEDDED_PLAYER,
                         WEB_MUSIC_ANALYTICS, ANDROID, IOS, plus the
                         WEB_REMIX values for completeness). Base URLs
                         + prettyPrint=false suffix.
  * client_request.rs  — ClientInfo / DeviceInfo / InnertubeClientRequestInfo
                         + the 5 factory constructors NPE exposes
                         (ofWebClient, ofWebEmbeddedPlayer, ofCharts,
                         ofAndroid, ofIos). build_envelope() emits the
                         InnerTube JSON in NPE's exact insertion order;
                         build_desktop_envelope() is the WEB-fast-path
                         used by search/browse/next/resolve_url/comments.
  * itag.rs            — 57-entry itag table (14 progressive + 10 audio +
                         33 video-only). MediaFormat enum + ItagType
                         enum + ItagItem struct + lookup().
  * parsing.rs         — consent toggle + cookie generator (SOCS=CAE= /
                         SOCS=CAISAiAD), WEB client-version cache + sw.js
                         scrape, WEB/mobile header builders (mobile
                         deliberately strips X-YouTube-Client-Name +
                         Origin/Referer + Cookie per audit Track A §6.2),
                         android/ios UA templates, visitor_data bootstrap
                         POST to /youtubei/v1/visitor_id.

PARITY notes flagged in code:
  * androidSdkVersion=36 + osVersion=16 but Android-15 in UA — NPE-intentional
  * mobile clients send NO X-YouTube-Client-* headers
  * audit doc says "53 entries" but tallies + NPE source = 57 ItagItems

Tests: 62 lib unit pass (up from 43 in Phase 2). All Phase 1 + Phase 2
smoke still green. Live InnerTube POSTs (visitor_data bootstrap +
/player) deferred to Phase 4 integration.
This commit is contained in:
Sulkta 2026-05-24 16:57:47 -07:00
parent 6ad0c52aaf
commit fb70166f5d
5 changed files with 863 additions and 3 deletions

View file

@ -1,5 +1,11 @@
// YouTube service tree. Phase 2 lands the JS deobfuscator (the keystone
// risk per SPEC §9). Phase 3+ lands the InnerTube client matrix, itag
// table, stream extractor, search, channel, etc.
// YouTube service tree. Phase 2 landed the JS deobfuscator. Phase 3 adds
// the InnerTube client matrix, request envelope, parsing helpers, and the
// itag table. Phase 4+ will add the stream extractor, search, channel,
// playlist, kiosks.
pub mod client_request;
pub mod constants;
pub mod itag;
pub mod js;
pub mod parsing;