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`;
}
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.
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
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