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

Getting an error on VERCEL but working fine on Google cloud run and localhost #113

Closed
altr opened this issue Aug 9, 2024 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@altr
Copy link

altr commented Aug 9, 2024

Describe the bug
I don't know whether it's a bug, however when hosting on VERCEL I'm consistently getting an error for
const video = await youtube.getVideo(id).
This issue doesn't occur on localhost and when hosted on Google Cloud Run.
The exact error message is:
Cannot read properties of undefined (reading 'videoId')

** Additional context**
This wasn't happening 4 weeks ago as this worked fine in the past. Could IP/Proxy or similar factors play a role here?

@altr altr added the bug Something isn't working label Aug 9, 2024
@mehdi89
Copy link

mehdi89 commented Aug 9, 2024

Same here, it's working in local, but not working from Vercel, Google cloud functions and Digital Ocean Server. Any Idea why or how to fix it ?

@MaitreGEEK
Copy link

Same here

@Donald646
Copy link

It's prob getting blocked, this happened on another library, I was hoping to switch here to avoid it, but ig not.

@MaitreGEEK
Copy link

Yep tried in youtube-sr too

@SuspiciousLookingOwl
Copy link
Owner

Your IP most likely got banned by google, there's nothing that I can do about this unfortunately.

However, I've implemented OAuth into this library, which allows you to send authenticated request, I used this too on my server (because my server got IP banned too) and it has been working fine. Usage:

const client = new Client({
    oauth: {
        enabled: true,
        refreshToken: "optional", // optional if you already have a refresh token 
    }
})

@MaitreGEEK
Copy link

Your IP most likely got banned by google, there's nothing that I can do about this unfortunately.

However, I've implemented OAuth into this library, which allows you to send authenticated request, I used this too on my server (because my server got IP banned too) and it has been working fine. Usage:

const client = new Client({
    oauth: {
        enabled: true,
        refreshToken: "optional", // optional if you already have a refresh token 
    }
})

Is there any way to have multiple tokens ? I have a list of cookies and would like to use it with youtubei for a big API

@SuspiciousLookingOwl
Copy link
Owner

I'm not sure if I'm going to implement that into the library, I feel like it's out of the library's scope, but I'll consider it.

The closest thing you can do right now is to create multiple youtubei client and roll them

Example (not tested):

import { Client } from "youtubei";

const refreshTokens = ["...", "...", "..."];

const clients = refreshTokens.map(refreshToken => new Client({
    oauth: {
        enabled: true,
        refreshToken,
    }
}));

const videoIds = ["...", "...", "..."];

let currentClientIndex = 0;

const getVideo = async (videoId: string) => {
    if (currentClientIndex >= clients.length) {
        currentClientIndex = 0;
    }
    const client = clients[currentClientIndex];
    return client.getVideo(videoId);
}

for (const videoId of videoIds) {
    getVideo(videoId).then(video => {
        console.log(video.title);
    }).catch(console.error);
}

@MaitreGEEK
Copy link

Yeah great idea thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants