ybd-project / ytdl-core

Fast and secure YouTube downloader for JavaScript and TypeScript
MIT License
22 stars 3 forks source link

Error: All player APIs responded with an error. (Clients: web_creator, ios, android) #7

Closed sslexus closed 3 weeks ago

sslexus commented 3 weeks ago

Describe the bug

Thanks for the fork!

I encountered a strange error using poToken & visitorData approach like so :

    const videoID = "1oFQamxoFy0";
    const poToken = "...";
    const visitorData = "..."

    const info = await ytdl.getInfo(videoID, { poToken, visitorData });

    // Filter for audio formats
    const audioFormats = ytdl.filterFormats(info.formats, "audioonly");
    const format = ytdl.chooseFormat(audioFormats, { quality: "highestaudio" });

    // Create a PassThrough stream to capture the audio data
    const audioStream = new PassThrough();

    // Pipe the audio stream to the PassThrough stream
    ytdl
      .downloadFromInfo(info, { format, poToken, visitorData })
      .pipe(audioStream);

Here's the thing: I ran this in a REST endpoint, and it works locally. But once deployed (Vercel), not anymore. What would you suggest me here?

Error Details (Log)

 Error: All player APIs responded with an error. (Clients: web_creator, ios, android)

Environment

ybd-project commented 3 weeks ago

Thank you for presenting the issue. You can specify clients as the second argument of the getInfo function, so try specifying ['web_creator', 'ios', 'android', 'tv_embedded'] there.

ytdl.getInfo(VIDEO_URL, {
    poToken: 'PO_TOKEN',
    visitorData: 'VISITOR_DATA',
    clients: ['web_creator', 'ios', 'android', 'tv_embedded']
});

If this does not work, it is recommended to generate the poToken again.

(tv_embedded clients can be used to circumvent age restrictions, etc.)

ybd-project commented 3 weeks ago

Is the problem resolved?

sslexus commented 3 weeks ago

I finally resolved it by using a proxy agent @ybd-project . Thanks regardless!