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

Error 403, 410, Cannot play a resource that has already ended; Can't find music/video or write EPIPE when play by link #841

Closed
thnhmai06 opened this issue Oct 9, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@thnhmai06
Copy link

thnhmai06 commented Oct 9, 2021

Describe the bug
[PlayerError] Cannot play a resource that has already ended (and return error code 403 or 410)
Return Can't find music/video or write EPIPE when play by link

To Reproduce
Command Bot play music
Expected behavior
Bot play music

Screenshots
image
image
image
image
image

Please complete the following information:

  • Node Version: 16.11.0
  • Discord Player Version: 5.1.0
  • Discord.js Version: 13.2.0
  • FFmpeg-static Version: 4.4.0

Additional context
Code:

main.js:

//{code}

client.player = new Player(client, {
    ytdlDownloadOptions: {
        filter: "audioonly"
    }
});

client.player.on("error", (queue, error) => {
    console.log(colors.red(`Lỗi trong hàng đợi: ${error.message}`));
    queue.metadata.send(`❌ | Lỗi trong hàng đợi: ` + "`" + `${error.message}` + "`" + `. Vui lòng thử lại sau`)
});
client.player.on("connectionError", (queue, error) => {
    console.log(colors.red(`Lỗi kết nối: ${error.message}`));
    queue.metadata.send(`❌ | Lỗi kết nối: ` + "`" + `${error.message}` + "`" + `. Vui lòng thử lại sau`)
});

client.player.on("trackStart", (queue, track) => {
    queue.metadata.send(`🎶 | Bắt đầu phát **${track.title}** trong **${queue.connection.channel.name}**!`);
});

client.player.on("trackAdd", (queue, track) => {
    queue.metadata.send(`🎶 | Bài **${track.title}** đã được thêm vào hàng đợi!`);
});

client.player.on("botDisconnect", (queue) => {
    queue.metadata.send("❌ | Xóa hàng đợi do bị ngắt kết nối khỏi kênh nói thủ công!");
});

client.player.on("channelEmpty", (queue) => {
    queue.metadata.send("❌ | Tự thoát do không có người nghe");
});

client.player.on("queueEnd", (queue) => {
    queue.metadata.send("**✅ | Đã phát xong!** *Nếu bài của bạn vẫn chưa được phát, vui lòng thử lại*");
});

//{some code}

play.js:

const Discord = require('discord.js')
const { Player, QueryType, QueueRepeatMode } = require("discord-player");

module.exports = {
    name: "play",
    description: "play songs",

    async run (client, message, args) {
        const player = client.player;
        if (!message.member.voice.channel) return message.channel.send("❌ | **Bạn phải ở trong một kênh nói!**");
        if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(":x: | **Bạn phải ở cùng kênh nói với Bot!**"); 

        const queue = await player.createQueue(message.guild, {
            metadata: message.channel
        });
        try {
            if (!queue.connection) await queue.connect(message.member.voice.channel);
        } catch {
            queue.destroy();
            return message.channel.send("❌ | Đã xảy ra lỗi khi tham gia kênh nói!");
        }
        const searchResult = await player.search(args.join(" "), {
            requestedBy: message.user,
            searchEngine: QueryType.AUTO
        })
        if (!searchResult || !searchResult.tracks.length) return message.channel.send("❌ | Không tìm thấy nhạc/video hoặc đã xảy ra lỗi khi tìm kiếm");
        message.channel.send(`⏱ | Đang tải ${searchResult.playlist ? "danh sách phát" : "bài nhạc"}...` );
        if (searchResult.playlist) {queue.addTracks(searchResult.tracks)} else {queue.addTrack(searchResult.tracks[0])};
        if (!queue.playing) await queue.play();
    }
}

Run Command : node --max-old-space-size=4096 main.js

@thnhmai06 thnhmai06 added the bug Something isn't working label Oct 9, 2021
@pj0us
Copy link

pj0us commented Oct 10, 2021

are u using ffmpeg-static package ?

@thnhmai06
Copy link
Author

are u using ffmpeg-static package ?

yes

@pj0us
Copy link

pj0us commented Oct 10, 2021

That why u have EPIPE error, uninstall ffmpeg-static package cuz that package is not stable. Let download ffmpeg from https://www.ffmpeg.org/download.html
and about error 410, it will reduce if you use cookies
about error 403, i asked ytdl and they said "there is no way to fix yet, its probably caused on youtube's side"

@thnhmai06
Copy link
Author

thnhmai06 commented Oct 10, 2021

Đó là lý do tại sao bạn bị lỗi EPIPE, hãy gỡ cài đặt gói ffmpeg-static vì gói đó không ổn định. Hãy tải xuống ffmpeg từ https://www.ffmpeg.org/download.html và về lỗi 410, nó sẽ giảm nếu bạn sử dụng cookie về lỗi 403, tôi đã hỏi ytdl và họ nói "không có cách nào để sửa chữa, có thể là của nó. gây ra từ phía youtube "

But unfortunately I host the bot on Railway, it's the same as Heroku (Using heroku/buildpacks). Therefore, using FFmpeg is not possible (must use FFmpeg-static).

@pj0us
Copy link

pj0us commented Oct 10, 2021

i asked them, and they said u can install ffmpeg by use dockerfile

@thnhmai06
Copy link
Author

i asked them, and they said u can install ffmpeg by use dockerfile

Is there any other way?

@pj0us
Copy link

pj0us commented Oct 10, 2021

i think no :(

@willm132
Copy link

Has anyone found a stable fix for this?

@twlite
Copy link
Collaborator

twlite commented Oct 17, 2021

This problem is with youtube itself, we cannot fix this from here. You can take a look at https://github.com/fent/node-ytdl-core and see if they can do something about this

@Tejas12972
Copy link

i asked them, and they said u can install ffmpeg by use dockerfile

can you send the specific dockerfile for it?

@twlite
Copy link
Collaborator

twlite commented Dec 20, 2021

@tomihbk
Copy link

tomihbk commented Apr 6, 2022

Any new developments on this issue?

@twlite twlite unpinned this issue Mar 4, 2023
@twlite twlite pinned this issue Mar 4, 2023
@twlite
Copy link
Collaborator

twlite commented Mar 4, 2023

Any new developments on this issue?

complete rewrite of queue system was done https://github.com/Androz2091/discord-player/releases/tag/v6.0.0

@twlite twlite unpinned this issue Mar 16, 2023
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

6 participants