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

Age restricted YT song not extracting @discord-player version: 6.6.2 @discord-player/extractor version: 4.4.1 #1793

Closed CursedHorus closed 1 year ago

CursedHorus commented 1 year ago

Describe the bug When attempting to get the discord bot (discord.js version: 14.12.0) to play age restricted music (either via a song search / URL or in a playlist) I receive the following error message:

ERR_NO_RESULT: Could not extract stream for this track

Error: Failed to parse stream url for https://www.youtube.com/watch?v=7EqnoEljHCw at _YoutubeExtractor._stream (/home/cursed/Documents/Discord App/node_modules/@discord-player/extractor/dist/index.js:274:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Loading the Youtube URL / link it is asking to sign in, so my assumption is the error is caused by the @discord-player/extractor YouTube extractor not being able to actually sign into YT to then get around the restriction.

I'm running the following dependencies and versions:

"dependencies": { "@discord-player/extractor": "^4.4.1", "@discord-player/ffmpeg": "^0.1.0", "@discordjs/builders": "^1.6.3", "@discordjs/node-pre-gyp": "^0.4.5", "@discordjs/opus": "^0.9.0", "@discordjs/rest": "^1.7.1", "@discordjs/voice": "^0.16.0", "@distube/ytdl-core": "^4.11.17", "@sapphire/discord.js-utilities": "^7.0.1", "discord-api-types": "^0.37.51", "discord-player": "^6.6.2", "discord.js": "^14.12.0", "dotenv": "^16.3.1", "ffmpeg-static": "^5.1.0", "node-gyp": "^9.4.0", "node-pre-gyp": "^0.17.0", "opusscript": "^0.0.8" }

I am running this on an ARM64 CPU on a Rasberry Pi 4 Model B - if that helps.

To Reproduce Steps to reproduce the behaviour:

  1. attempt to play https://www.youtube.com/watch?v=7EqnoEljHCw (F You by Dr. Dre) via the music bot in discord
  2. check the console / terminal / log for the error during the extraction process

Expected behaviour The Discord bot to play the song in the voice channel, all other elements of the bot are functioning. I am happy to get it to sign into YT with some credentials (i can create a simple account on YT and get it to use that) I would just need to know the cli / terminal command to get the extractor to log in.

Please complete the following information:

twlite commented 1 year ago

@CursedHorus the video you are trying to play seems to be age restricted. You can try adding cookies as mentioned in https://discord-player.js.org/guide/youtube/cookies to get around this issue. I cannot guarantee for it to 100% work but give it a shot.

Loading the Youtube URL / link it is asking to sign in, so my assumption is the error is caused by the @discord-player/extractor YouTube extractor not being able to actually sign into YT to then get around the restriction.

@discord-player/extractor is not responsible for this. If your bot is able to find the track, the extractor is already working great. Streaming issue like this happens on the streaming library, in this case you are using @distube/ytdl-core. You can use the following code to properly debug this type of issues

const { useMainPlayer } = require('discord-player');

client.once('ready', () => {
    const player = useMainPlayer();

    // generate dependencies report
    console.log(player.scanDeps());
    // ^------ This is similar to @discordjs/voice's `generateDependenciesReport()` function, but with additional informations related to discord-player

    // log metadata query, search execution, etc.
    player.on('debug', console.log);
    // ^------ This shows how your search query is interpreted, if the query was cached, which extractor resolved the query or which extractor failed to resolve, etc.

    // log debug logs of the queue, such as voice connection logs, player execution, streaming process etc.
    player.events.on('debug', (queue, message) => console.log(`[DEBUG ${queue.guild.id}] ${message}`));
    // ^------ This shows how queue handles the track. It logs informations like the status of audio player, streaming process, configurations used, if streaming failed or not, etc.
});
CursedHorus commented 1 year ago

@skdhg Thank you for clearing up where the issue is, and for the quick response

CursedHorus commented 1 year ago

@skdhg sorry to ask, but are you able to help me digest what the errors are saying?:

[DEBUG 1098914750315892877] Requested option requires to play the track, initializing... [DEBUG 1098914750315892877] Initiating stream extraction process... [DEBUG 1098914750315892877] Executing onBeforeCreateStream hook (QueryType: youtubeVideo)... [DEBUG 1098914750315892877] Failed to get stream from onBeforeCreateStream! [DEBUG 1098914750315892877] Attempting to extract stream for Track { title: Fuck You, url: https://www.youtube.com/watch?v=7EqnoEljHCw } using registered extractors Executing extractor com.discord-player.youtubeextractor... Extractor com.discord-player.youtubeextractor failed with error: Error: Failed to parse stream url for https://www.youtube.com/watch?v=7EqnoEljHCw [DEBUG 1098914750315892877] Failed to extract stream for Track { title: F**k You, url: https://www.youtube.com/watch?v=7EqnoEljHCw } using registered extractors [DEBUG 1098914750315892877] Failed to initialize audio player: ERR_NO_RESULT: Could not extract stream for this track

Note the dependencies that loaded if it helps:

Discord Player

Loaded Extractors:

N/A

@discordjs/voice

Core Dependencies

Opus Libraries

Encryption Libraries

FFmpeg

twlite commented 1 year ago

it indicates it failed to parse stream url for that track

CursedHorus commented 1 year ago

Meaning that the streaming side isn't working, so my options are move to a different streaming library. Which one would you recommend?

The bot is a discord bot, only playing Youtube and Spotify songs if this helps your recommendation?

twlite commented 1 year ago

The bot is a discord bot, only playing Youtube and Spotify songs if this helps your recommendation?

You can use whatever works the best. Based on our testing, ytdl-core seems to be the most broken one.

You can try https://github.com/zyrouge/node-youtube-ext

CursedHorus commented 1 year ago

Still seems to be getting the issue even with a uninstall of distube/ytdl-core and an install of the one you linked.

I will raise a issue with them to see if it's something they know about etc. Thanks.

CursedHorus commented 1 year ago

Just putting the resolution here:

I made a mistake in my player creation:

client.player = new Player(client, { ytdlOptions: { quality: 'highestaudio', highWaterMark: 1 << 25, requestOptions: { headers: { cookie: YOUTUBE_COOKIE, } } } });

i put ytdloptions - not ytdlOptions, it is case sensitive and it now works perfectly with the restricted songs