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

Streaming URLs failing due to PoToken experiment #724

Open
rustynail1984 opened this issue Aug 6, 2024 · 7 comments
Open

Streaming URLs failing due to PoToken experiment #724

rustynail1984 opened this issue Aug 6, 2024 · 7 comments

Comments

@rustynail1984
Copy link

Hi,

i want to report that all extracted googlevideo urls using WEB Client (Encrypted and non encrypted videos) respoding with 403 error.

I guess its the nsig again.

Can someone confirm this?

Thanks.

@LuanRT
Copy link
Owner

LuanRT commented Aug 6, 2024

Unfortunately no, it's more complicated than that.
This is due to YouTube expecting you to pass in a PoToken.

See #708.

@rustynail1984
Copy link
Author

rustynail1984 commented Aug 6, 2024

Unfortunately no, it's more complicated than that. This is due to YouTube expecting you to pass in a PoToken.

See #708.

I pass a poToken and visitor data in the player API request. It has worked fine for two days now. But since few hours all extracted googlevideo urls responding with 403 error.

Edit: ohhh i see now.. it expect a pot parameter in the googlevideo urls with the poToken value

Edit2: After adding pot parameter to the googlevideo streaming urls it works for the most videos. i renewing the poToken and visitorData all 2 hours automatically with my puppeteer script.

@LuanRT LuanRT changed the title NSIG issue again? Extracted YouTube urls responding 403 Streaming URLs failing due to PoToken experiment Aug 8, 2024
@RatWasHere
Copy link

@rustynail1984 would you mind sharing your puppeteer script?

@retrouser955
Copy link

retrouser955 commented Aug 10, 2024

@RatWasHere this is my puppeteer script modelled after iv-org's trusted session generator

You modify this code by using the promise API to wait for the poToken to be intercepted.

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
    headless: false
})

// start scraping youtube!
const page = await browser.newPage()

// laymen's terms: Turn on chrome dev tools
const client = await page.createCDPSession();
await client.send('Debugger.enable');
await client.send('Debugger.setAsyncCallStackDepth', { maxDepth: 32 });
await client.send('Network.enable');

// Intercept requestWillBeSent from the dev tools
client.on("Network.requestWillBeSent", (e) => {
    if(e.request.url.includes("/youtubei/v1/player")) {
        const jsonData = JSON.parse(e.request.postData)

        // Extractor PO Token and visitor data
        console.log(`PO TOKEN: ${jsonData["serviceIntegrityDimensions"]["poToken"]}`)
        console.log(`VISITOR DATA: ${jsonData["context"]["client"]["visitorData"]}`)

        browser.close()
    }
})
// Go to a YouTube embed
await page.goto("https://www.youtube.com/embed/jNQXAC9IVRw", {
    waitUntil: "networkidle2"
})

// Start playing the video
const playButton = await page.$("#movie_player")

await playButton.click()

@Elite
Copy link

Elite commented Aug 11, 2024

@retrouser955 Do you need to be logged in for a valid PO token?

@retrouser955
Copy link

@Elite I don't believe so.

@rogerpadilla
Copy link
Contributor

@Elite i think the script above that uses pptr doesn't work properly in remote servers but the BgUtils script from LuanRT works fine.

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

No branches or pull requests

6 participants