Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
590 stars 192 forks source link

Error: Status code: 404 #539

Closed Aayansh549 closed 3 years ago

Aayansh549 commented 3 years ago

20210622_145036 I'm getting status code 404 error. How can I terminate that or resolve that. It shows when track is added to the queue. Not sure when. It's generated but how can I resolve that.

Positive2022 commented 3 years ago

Not sure about terminating this issue, but u can use the error event to handle this error. Also is it happening everytime u play song? What version of discord-player is it?

twlite commented 3 years ago

fent/node-ytdl-core#923

will do something about this in the next release

Aayansh549 commented 3 years ago

Because of that error sometimes song also not start to play. That's not always done when trackAdded it's random and it's showing on play song or track or whatever. Not always. I'm using V4.1.1 of discord-player.

twlite commented 3 years ago

@Aayansh549 This is a bug in ytdl-core itself

Samiul30 commented 3 years ago

I have also encountered this bug just now.

twlite commented 3 years ago

Can you guys try using https://www.npmjs.com/package/@discord-player/downloader 🤔 Also, do npm install discord-player@beta before using that

Samiul30 commented 3 years ago

Can you guys try using https://www.npmjs.com/package/@discord-player/downloader 🤔 Also, do npm install discord-player@beta before using that

I got err with no stream source provided. Just install discord-player@beta and use player.use for extractor.

twlite commented 3 years ago

Can you guys try using https://www.npmjs.com/package/@discord-player/downloader 🤔 Also, do npm install discord-player@beta before using that

I got err with no stream source provided. Just install discord-player@beta and use player.use for extractor.

yeah that was my fault by not exporting stream engine. Can you install the extractor again? The latest version??

Samiul30 commented 3 years ago

Can you guys try using https://www.npmjs.com/package/@discord-player/downloader 🤔 Also, do npm install discord-player@beta before using that

I got err with no stream source provided. Just install discord-player@beta and use player.use for extractor.

yeah that was my fault by not exporting stream engine. Can you install the extractor again? The latest version??

Discord-player downloader?

twlite commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });
twlite commented 3 years ago

You need to handle playlists in similar way. Else you may get status code 404

rilysh commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

Thank you! It's works perfectly, but one problem is when I use discord extractor module along with discord-player it's a little bit slow than before, (I using replit), but anyway, It's work!

Coolkid2342 commented 3 years ago

After adding this, still causes a 404 error.

rilysh commented 3 years ago

One more problem which I notice that I can't loop a track, it's saying memory leak problem, trying to enable emitter.setMaxListeners()but still giving this warning on console.

 (node:1351) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit
(node:1351) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit
Samiul30 commented 3 years ago

One more problem which I notice that I can't loop a track, it's saying memory leak problem, trying to enable emitter.setMaxListeners()but still giving this warning on console.

 (node:1351) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit
(node:1351) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit

This is due to hosting in repl

onepiecehung commented 3 years ago

Oh, i got same error: image

Uryaaa commented 3 years ago

Yep

Oh, i got same error: image

Same

twlite commented 3 years ago

Those who got the issue, you can use this temporary solution

DragonTahmid1 commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

yeah that works but the play needs like 1-2 minutes to play and some times the music is too laggy but works fine :)

ghost commented 3 years ago

After adding this, still causes a 404 error.

Same for me

chinmayraj28 commented 3 years ago

After adding this, still causes a 404 error.

Same for me

Yes, same here

Samiul30 commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

Everything is fine but how to get the filter work? And the pause?

Killerpac commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

This Fix Works but it messes with the livestream videos and Spotify playback

There is a PR in node-ytdl-core repo where it fixes the 404 problem better fork it and merge the commits manually As a temporary fix but that also crashes

ghost commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

This Fix Works but it messes with the livestream videos and Spotify playback

There is a PR in node-ytdl-core repo where it fixes the 404 problem better fork it and merge the commits manually As a temporary fix but that also crashes

For me this fix doesn't fix anything. The bot continues to throw a 404 error after it was given a youtube link.

YashDevOP commented 3 years ago

how to fix this in repl.it?

DragonTahmid1 commented 3 years ago

how to fix this in repl.it?

temporary solution works in replit.com too

but can appear eventEmitter error (above someone posted it)

leunamcrack commented 3 years ago

For users can edit node_modules go to node_modules/ytld-core/lib/info.js, delete and paste this code

For replit users can use this method:

  1. Create a file info.js and copy/paste this code
  2. Put the following code into index.js or the main node file
    try {
    let file = fs.readFileSync(__dirname + "/info.js");
    fs.writeFileSync(__dirname + "/node_modules/ytdl-core/lib/info.js", file);
    } catch (error) {
    console.log(error);
    }
  3. Restart and ready

EDIT:

I hope works for you

VarnishDas commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

It's working, thanks a lot!

DragonTahmid1 commented 3 years ago

For users can edit node_modules go to node_modules/ytld-core/lib/info.js, delete and paste this code

For replit users can use this method

  1. Create a file info.js and copy/paste this code
  2. Put the following code into index.js or the main node file
try {
    let file = fs.readFileSync(__dirname + "/info.js");
    fs.writeFileSync(__dirname + "/node_modules/ytdl-core/lib/info.js", file);
} catch (error) {
    console.log(error);
}

(Remember install and define fs module)

  1. Restart and ready

I hope works for you

worksss!!! fast than the temporary solution (everyone reading this, try this :D) i tried it in replit.

SkyAlumny commented 3 years ago

For users can edit node_modules go to node_modules/ytld-core/lib/info.js, delete and paste this code

For replit users can use this method

  1. Create a file info.js and copy/paste this code
  2. Put the following code into index.js or the main node file
try {
    let file = fs.readFileSync(__dirname + "/info.js");
    fs.writeFileSync(__dirname + "/node_modules/ytdl-core/lib/info.js", file);
} catch (error) {
    console.log(error);
}

(Remember install and define fs module)

  1. Restart and ready

I hope works for you

Thanks !

Coolkid2342 commented 3 years ago

same here fixed it for me after changing the file.

Samiul30 commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

This Fix Works but it messes with the livestream videos and Spotify playback

There is a PR in node-ytdl-core repo where it fixes the 404 problem better fork it and merge the commits manually As a temporary fix but that also crashes

For me this fix doesn't fix anything. The bot continues to throw a 404 error after it was given a youtube link.

With this temporary solution, the seek , filter, repeate mode is not working. Any one face this issue?

alima566 commented 3 years ago

Run

npm install discord-player@latest npm install @discord-player/downloader@latest

Update

// after client.player = new Player(client)
client.player.use("YOUTUBE_DL", require("@discord-player/downloader").Downloader);

// in your play command
const { Util } = require("discord-player");

if (Util.isURL(args.join(" "))) return client.player.play(message, args.join(" "), { firstResult: true });
const tracks = await Util.ytSearch(args.join(" "), {
    user: message.author,
    player: client.player
}).catch(() => {});

if (!tracks || !tracks.length) return message.channel.send("Track not found!");

client.player.play(message, tracks[0].url, { firstResult: true });

This did not work for me. I followed this exactly and I'm still getting the 404 error.

devPhytols commented 3 years ago

Para que os usuários possam editar node_modules, vá para node_modules/ytld-core/lib/info.js, exclua e cole este código Para usuários substitutos pode usar este método

  1. Crie um arquivo info.js e copie / cole este código
  2. Coloque o seguinte código em index.js ou no arquivo do nó principal
try {
    let file = fs.readFileSync(__dirname + "/info.js");
    fs.writeFileSync(__dirname + "/node_modules/ytdl-core/lib/info.js", file);
} catch (error) {
    console.log(error);
}

(Remember install and define fs module)

  1. Reinicie e pronto

Espero que funcione para você

worksss !!! mais rápido do que a solução temporária (todos que estão lendo isso, tente isso: D) eu tentei em replit.

thanks bro <3

twlite commented 3 years ago

FIX

DragonTahmid1 commented 3 years ago

FIX

* `npm r @discord-player/downloader`

* `npm i discord-player@latest`

works! i tried it in my second bot and worked, in the first one i tried that info.js solution from above, ty for fixing it this will result useful to people who waited this long using @discord-player/downloader