mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-27 16:06:47 -05:00
Replace the plain /youtubei/v1/player request (made through the proxy, and therefore bound to the proxy's egress IP) with an encrypted Onesie request using the WEB client. Onesie is proxied by YouTube's "trusted bandaid", so the returned player response - and the server_abr_streaming_url inside it - is not tied to our egress IP. Media is still pulled over SABR (sabr_scheme_plugin.js); only how the player response is obtained changes. - sabr_onesie.js: new module, window.fetchOnesiePlayerResponse(). Builds the WEB player request, encrypts it (OnesieInnertubeRequest + OnesieRequest), POSTs to the onesie endpoint through /proxy, parses ONESIE_HEADER/ONESIE_DATA UMP parts, gunzips/decrypts, returns the raw player response JSON. Adapted from googlevideo/examples/onesie-request and invidious-secret-companion's WEB-client variant. - sabr_helpers.js: add decryptResponse() (AES-CTR + HMAC verify), companion to the existing encryptRequest(). - sabr_loader.js: expose window.YT so a VideoInfo can be built from the raw onesie player response. - sabr_player.js: in loadVideo(), fetch the player response via Onesie and wrap it in new YT.VideoInfo(...); fall back to innertube.getInfo() on failure. - player.ecr: load sabr_onesie.js before sabr_player.js. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
/**
|
|
* SABR Loader - ES module loader for SABR dependencies
|
|
*
|
|
* All dependencies are ES modules:
|
|
* - youtubei.js: Provides Innertube for YouTube API access
|
|
* - googlevideo: Provides SABR protos, UMP reader/writer and utils
|
|
* - bgutils-js: Provides BotGuard utilities
|
|
*
|
|
* Exposes everything needed by sabr_scheme_plugin.js / sabr_manifest_parser.js
|
|
* onto window.googlevideo so the plain-script plugin can read them at call time.
|
|
*/
|
|
|
|
import Innertube, { Platform, Constants, YT } from '/js/sabr/youtubei.js/youtubei.bundle.min.js';
|
|
import { googlevideo } from '/js/sabr/googlevideo/googlevideo.bundle.min.js';
|
|
import { BG } from '/js/sabr/bgutils-js/bgutils.bundle.min.js';
|
|
|
|
// youtubei.js
|
|
window.Innertube = Innertube;
|
|
window.Platform = Platform;
|
|
window.Constants = Constants;
|
|
// YT.VideoInfo: build a VideoInfo from a raw player response fetched via the
|
|
// onesie path (sabr_onesie.js) instead of innertube.getInfo().
|
|
window.YT = YT;
|
|
|
|
// googlevideo namespace (utils, ump, protos) for the SABR scheme plugin + manifest parser
|
|
window.googlevideo = googlevideo;
|
|
|
|
// BotGuard
|
|
window.BG = BG;
|
|
|
|
console.info('[SABR Loader]', 'All SABR libraries loaded');
|
|
window.dispatchEvent(new Event('sabr-libs-loaded')); |