node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

Miniget Error: Status code: 410

Open dev-syn opened this issue 1 year ago • 12 comments

I have noticed that an issue like this is happening and I've tried following through on what has been said to try and fix it.

async function playSong(guildID: string,song: Video): Promise<void> {
    return new Promise<void>((resolve, reject) => {
        let videoStream: internal.Readable | null = null;
        try {
            // Download the video
            videoStream = ytdl(song.url,{
                quality: "highestaudio",
                dlChunkSize: 0,
                requestOptions: {
                    headers: {
                        cookie: process.env.YT_COOKIE,
                        "x-youtube-identity-token": process.env.YT_TOKEN
                    }
                }
            });
        } catch(err) { return reject(err); }

        processVideo(videoStream)
        .then((voiceData: Buffer) => {
            const guildPlayer: AudioPlayer = guildAudioPlayers.ensure(guildID,() => createAudioPlayer());
            const resource: AudioResource = createAudioResource(Readable.from([voiceData]));
            try {
                guildPlayer.play(resource);
                resolve();
            } catch(err) { return reject(err); }
        })
        .catch(err => reject(new Error("Failed to play song with error: " + err.message)));

    });
}

This is where I'm using ytdl and from what I noticed when I try and play an age restricted/suicide topic song I get this output

[14:51:27] ERROR: Status code: 410
    err: {
      "type": "MinigetError",
      "message": "Status code: 410",
      "stack":
          Error: Status code: 410
              at ClientRequest.<anonymous> (E:\MyDev\_Projects\Discord\dscrd-TheDirector\node_modules\miniget\src\index.ts:255:19)
              at Object.onceWrapper (node:events:628:26)
              at ClientRequest.emit (node:events:513:28)
              at HTTPParser.parserOnIncomingClient (node:_http_client:701:27)
              at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
              at TLSSocket.socketOnData (node:_http_client:542:22)
              at TLSSocket.emit (node:events:513:28)
              at addChunk (node:internal/streams/readable:324:12)
              at readableAddChunk (node:internal/streams/readable:297:9)
              at TLSSocket.Readable.push (node:internal/streams/readable:234:10)
      "statusCode": 410
    }

For example trying to play: https://www.youtube.com/watch?v=yNjWAjXTryE

If I go to youtube manually and try and play this song I get the popup from youtube saying

The following content may contain suicide or self-harm topics. Viewer discretion is advised.

I understand and wish to proceed.

I read from another issue that doing the cookies would allow me to view this content and even after doing so I still receive the error above.

EDIT: I also tried the fix in #1080

const url: string = parseAgeYTUrl(song);
Logger.info("Getting song with url: " + url);
let info: ytdl.videoInfo | undefined = undefined;
try {
    info = await ytdl.getBasicInfo(url,{
          requestOptions: {
              headers: {
                  cookie: process.env.YT_COOKIE,
                  "x-youtube-identity-token": process.env.YT_TOKEN
              }
          }
      });
} catch(err) { Logger.error(err); }
function parseAgeYTUrl(input: string) {
    return `${input}&bpctr=${Date.now()}&has_verified=1`;
}

dev-syn avatar Jun 04 '23 14:06 dev-syn

Actually the fix from #1080 is something that must be done internally in the lib. If you want to try using my fork, which fixes this error and some others, put in your package.json:

"ytdl-core": "github:eugabrielsilva/node-ytdl-core"

eugabrielsilva avatar Jun 07 '23 21:06 eugabrielsilva

Actually the fix from #1080 is something that must be done internally in the lib. If you want to try using my fork, which fixes this error and some others, put in your package.json:

"ytdl-core": "github:eugabrielsilva/node-ytdl-core"

Ok I'll try that out thank you

dev-syn avatar Jun 08 '23 19:06 dev-syn

Actually the fix from #1080 is something that must be done internally in the lib. If you want to try using my fork, which fixes this error and some others, put in your package.json:

"ytdl-core": "github:eugabrielsilva/node-ytdl-core"

Legend, thank you for fixing it! I'll leave the issue open in hopes that the original repo will fix it too.

dev-syn avatar Jun 09 '23 01:06 dev-syn

Actually the fix from #1080 is something that must be done internally in the lib. If you want to try using my fork, which fixes this error and some others, put in your package.json:

"ytdl-core": "github:eugabrielsilva/node-ytdl-core"

Hey again this is the only place where I can message you but I went away from my bot for a bit and just started working on it again and when trying to use your fork I get this output

S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\cache.js:29
      let value = fn();
                  ^
TypeError: utils.request is not a function
    at S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\sig.js:19:28
    at Cache.getOrSet (S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\cache.js:29:19)
    at Object.exports.getFunctions (S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\sig.js:18:68)
    at Object.exports.decipherFormats (S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\sig.js:166:33)
    at exports.getInfo (S:\MyDev\_Projects\Discord\GeneralBot\node_modules\ytdl-core\lib\info.js:390:20)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Edit: I chose to go back to the specific commit github:eugabrielsilva/node-ytdl-core#f8b44b6727be87da46f6dbabc6f46e4efbd96436 and it works again so I believe it has to do with some recent change

dev-syn avatar Aug 24 '23 06:08 dev-syn

Hey everyone, it seems like the fork isn't available anymore. Is there an alternative?

JenerNiklas avatar Sep 27 '23 17:09 JenerNiklas

Yeah I just found that out too it really sucks

dev-syn avatar Sep 27 '23 19:09 dev-syn

Actually the fix from #1080 is something that must be done internally in the lib. If you want to try using my fork, which fixes this error and some others, put in your package.json:

"ytdl-core": "github:eugabrielsilva/node-ytdl-core"

Is there a reason you removed your fork?

dev-syn avatar Sep 27 '23 19:09 dev-syn

I'm running into this issue too. Any chance that the core library will fix this?

bboynton97 avatar Nov 03 '23 20:11 bboynton97

hey @bboynton97 @dev-syn @JenerNiklas, i deleted the fork because stopped working on it after i found a lot of new bugs... alternatively I've migrated to @distube/ytdl-core

eugabrielsilva avatar Nov 03 '23 22:11 eugabrielsilva

hey @bboynton97 @dev-syn @JenerNiklas, i deleted the fork because stopped working on it after i found a lot of new bugs... alternatively I've migrated to @distube/ytdl-core

Ah, thank you for this will migrate to this as well

dev-syn avatar Nov 05 '23 14:11 dev-syn

any update? i still got thí error

Namnp1521 avatar May 05 '24 03:05 Namnp1521

any update? i still got thí error

found that @distube/ytdl-core works

ItsAnoch avatar May 05 '24 04:05 ItsAnoch