Giter Club home page Giter Club logo

Comments (25)

skick1234 avatar skick1234 commented on July 28, 2024 1

@skick1234 thank you. By crossposting you mean it's not allowed to post links to other repos that could inform a question I have here? Or is it just something you personally don't want to happen here?

Actually, it is my fault since I didn't change the issue title. This issue is about his cookies cannot bypass the age gate. So it is not related to your question at all. Feel free to create a new issue for additional questions or feature requests.

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024 1

@ldenoue and as I said above, you still need cookies if you don't want to get rate limited (429). So I don't think it is necessary to implement another way to bypass age-restricted content. If you still need it, just create a feature request and I will investigate it in a nice day (or close as not planned 🤣)

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

I would also add maybe if my cookie expired but I just got the cookie yesterday so I'm not sure if they expire within a day but other then that I'm not aware on how I can fix this

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

https://github.com/distubejs/ytdl-core#cookies-support
If you added them, your cookies might be expired. There are many reasons to make your cookies revoked (log out, multiple IPs, etc). Anyway, it is not what we can handle with this project. Just get your cookie again until it works.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

https://github.com/distubejs/ytdl-core#cookies-support If you added them, your cookies might be expired. There are many reasons to make your cookies revoked (log out, multiple IPs, etc). Anyway, it is not what we can handle with this project. Just get your cookie again until it works.

Ok, thank you will do that.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

https://github.com/distubejs/ytdl-core#cookies-support If you added them, your cookies might be expired. There are many reasons to make your cookies revoked (log out, multiple IPs, etc). Anyway, it is not what we can handle with this project. Just get your cookie again until it works.

I just confirmed by getting my cookie again and it is not expired my expiration timestamp is: "expirationDate": 1735199412.856763

I'll provide everything in my cookie except the value

{
"domain": ".youtube.com",
"expirationDate": 1735199412.856763,
"hostOnly": false,
"httpOnly": true,
"name": "LOGIN_INFO",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": "0",
"id": 11
}

Which is today at like 8 AM but for me I'm writing this at 3 AM

This is my testing song: https://www.youtube.com/watch?v=rxZSYuzavhY

It works on the account when I go on it manually but not through the bot could it be anything else?

EDIT: I have logged out of the account and back in to refresh my cookie and even with the new cookie I still cannot play that song with the same error

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

Please provide your full code related to agent and ytdl

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

Please provide your full code related to agent and ytdl

async function playSong(guildPlayer: AudioPlayer,song: Song): Promise<void> {
    return new Promise<void>((resolve, reject) => {
        let videoStream: internal.Readable | null = null;
        try {
            Logger.info("Playing song with url: " + song.url);
            // Download the video
            videoStream = ytdl(song.url,{
                agent: agent,
                quality: "highestaudio"
            });
        } catch(err) { return reject(err); }

        processVideo(videoStream)
        .then((voiceData: Buffer) => {
            const resource: AudioResource = createAudioResource(Readable.from([voiceData]),{ inputType: StreamType.Opus });

            try {
                guildPlayer.play(resource);
                resolve();
            } catch(err) { return reject(err); }
        })
        .catch(err => reject(new Error("Failed to play song with error: " + typeof err === "string" ? err : err.message)));
    });
}

This is the getting of the cookie process

async function getYTCookie(): Promise<Cookie> {
    const content: string = await fs.readFile(path.join('_Data','yt-cookie.json'),'utf-8');
    const ytCookie: Cookie = JSON.parse(content);
    return ytCookie;
}

let agent: ytdl.Agent;
// Pass the yt cookie to the agent
getYTCookie()
.then((cookie: Cookie) => {
    agent = ytdl.createAgent([cookie]);
})
.catch(err => {
    Logger.warn(err,"Youtube cookie could not be fetched no cookie will be assigned.");
    agent = ytdl.createAgent();
});

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

I guess your cookie file is a cookie array, so you have to use ytdl.createAgent(cookie) instead of ytdl.createAgent([cookie]).
You should use zod to validate unknown json in ts.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

I guess your cookie file is a cookie array, so you have to use ytdl.createAgent(cookie) instead of ytdl.createAgent([cookie]). You should use zod to validate unknown json in ts.

It's not I thought of that ahead of time

Here is my whole json file excluding the value

{
    "domain": ".youtube.com",
    "expirationDate": 1735286838.909133,
    "hostOnly": false,
    "httpOnly": true,
    "name": "LOGIN_INFO",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "REDACTED",
    "id": 12
}

I then take this object and insert it into the array

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

I guess your cookie file is a cookie array, so you have to use ytdl.createAgent(cookie) instead of ytdl.createAgent([cookie]). You should use zod to validate unknown json in ts.

Have you tried reproducing this with the test song I sent because my bot will play any song that is not age restricted

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

Have you tried reproducing this with the test song I sent because my bot will play any song that is not age restricted

You don't need cookie to play other songs

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

Have you tried reproducing this with the test song I sent because my bot will play any song that is not age restricted

You don't need cookie to play other songs

Ok, but

let agent: ytdl.Agent;
// Pass the yt cookie to the agent
getYTCookie()
.then((cookie: Cookie) => {
    agent = ytdl.createAgent([cookie]);
})
.catch(err => {
    Logger.warn(err,"Youtube cookie could not be fetched no cookie will be assigned.");
    agent = ytdl.createAgent();
});

Here I have it log if the cookie could not be grabbed so it should be inserted into the agent.

Every song I try to play will route through playSong and in there I clearly do pass the agent.

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

Just try it and see.
We use CookieJar from tough-cookie, maybe it consider your nested array is an empty cookie without throwing errors.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

Just try it and see. We use CookieJar from tough-cookie, maybe it consider your nested array is an empty cookie without throwing errors.

I don't have a nested array? My json file is an object alone not inside of an array

Though I will try it for the sake of your help

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

Just try it and see. We use CookieJar from tough-cookie, maybe it consider your nested array is an empty cookie without throwing errors.

I don't have a nested array? My json file is an object alone not inside of an array

So you have to follow the guide in readme file and export all the cookies, not one cookie.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

Just try it and see. We use CookieJar from tough-cookie, maybe it consider your nested array is an empty cookie without throwing errors.

I don't have a nested array? My json file is an object alone not inside of an array

So you have to follow the guide in readme file and export all the cookies, not one cookie.

Ohh I'm sorry I assumed it was just the LOGIN_INFO cookie and the others were not required let me add all the other cookies my bad

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

i misread your #15 (comment), I think you said you have an array like that

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

i misread your #15 (comment), I think you said you have an array like that

No I believe you have identified my problem I only had the one cookie and not the others so let me try adding them and seeing if I can play the song

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

No I believe you have identified my problem I only had the one cookie and not the others so let me try adding them and seeing if I can play the song

Indeed, you need to provide an array of cookies. That's why I suggested using the extension to easily fetch all cookies, including HttpOnly cookies. I'll update the README to provide clearer instructions.

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

No I believe you have identified my problem I only had the one cookie and not the others so let me try adding them and seeing if I can play the song

Indeed, you need to provide an array of cookies. That's why I suggested using the extension to easily fetch all cookies, including HttpOnly cookies. I'll update the README to provide clearer instructions.

Yeah the issue is resolved thank you.

from ytdl-core.

ldenoue avatar ldenoue commented on July 28, 2024

@skick1234 and @dev-syn is there a way to get age restricted videos without cookies? e.g. it looks like the original ytdl-core had a way to use the /embed url to do this MAMISHO@dacb700

(although it doesn't seem to be working at the moment, see fent#19

from ytdl-core.

skick1234 avatar skick1234 commented on July 28, 2024

@skick1234 and @dev-syn is there a way to get age restricted videos without cookies? e.g. it looks like the original ytdl-core had a way to use the /embed url to do this MAMISHO@dacb700

(although it doesn't seem to be working at the moment, see fent#19

Don't crosspost. Old embed method doesn't work and you still need cookies to prevent 429.

from ytdl-core.

ldenoue avatar ldenoue commented on July 28, 2024

@skick1234 thank you. By crossposting you mean it's not allowed to post links to other repos that could inform a question I have here? Or is it just something you personally don't want to happen here?

from ytdl-core.

dev-syn avatar dev-syn commented on July 28, 2024

Yeah I'm not sure where I was going with that issue title that's my bad in the future I will try and be more specific.

from ytdl-core.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.