Skip to content

Commit

Permalink
chore(onesie-request): Use Application-Level Redirects
Browse files Browse the repository at this point in the history
+ Add `cmo:sensitive_content=yes` to the redirector request.
  • Loading branch information
LuanRT committed Nov 2, 2024
1 parent 3faff2f commit 96004ce
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions examples/onesie-request/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,10 @@ async function prepareOnesieRequest(args: OnesieRequestArgs): Promise<OnesieRequ
* Fetches basic video info (streaming data, video details, etc.) using a Onesie request (/initplayback).
*/
async function getBasicInfo(innertube: Innertube, videoId: string): Promise<YT.VideoInfo> {
const redirectorResponse = await fetch(`https://redirector.googlevideo.com/initplayback?source=youtube&itag=0&pvi=0&pai=0&owc=yes&id=${Math.round(Math.random() * 1E5)}`, {
method: 'GET',
redirect: 'manual'
});

const redirectorResponseUrl = redirectorResponse.headers.get('location');
const redirectorResponse = await fetch(`https://redirector.googlevideo.com/initplayback?source=youtube&itag=0&pvi=0&pai=0&owc=yes&cmo:sensitive_content=yes&alr=yes&id=${Math.round(Math.random() * 1E5)}`, { method: 'GET' });
const redirectorResponseUrl = await redirectorResponse.text();

if (!redirectorResponseUrl)
if (!redirectorResponseUrl.startsWith('https://'))
throw new Error('Invalid redirector response');

const clientConfig = await getYouTubeTVClientConfig();
Expand Down

0 comments on commit 96004ce

Please sign in to comment.