discord-player: YouTube stream fails with could not extract stream for this track

Discord Player throws could not extract stream for this track when trying to stream youtube source. This affects all the extractors that depend upon youtube streaming:

  • spotify extractor
  • apple music extractor
  • youtube extractor

Update 1 Streaming works upon removing ytdl-core and installing play-dl. This seems to be node-ytdl-core issue as mentioned in https://github.com/fent/node-ytdl-core/issues/1197. As a workaround, follow these steps:

  1. npm install play-dl or npm install @distube/ytdl-core
  2. add DP_FORCE_YTDL_MOD="play-dl" or DP_FORCE_YTDL_MOD="@distube/ytdl-core" in your .env file

If npm doesn’t work, clear npm cache and try again, or switch to another package manager like yarn.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 5
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Downgrading to ytdl-core@4.9.1 worked for me

@discord-player/extractor has ytdl-core as a peer dependency, so if you’re using that you’ll want to install play-dl then delete the ytdl-core folder inside of node_modules

You don’t have to modify node_modules. Set DP_FORCE_YTDL_MOD="play-dl" environment variable to prioritize specific lib.

Downgrading to ytdl-core@4.9.1 make the stream url download bottleneck and the music is not playing smoothly play-dl can play normal youtube link but it doesn’t support live stream url (Error: Could not extract stream for this track)

My solution Using @distube/ytdl-core fork (https://github.com/Androz2091/discord-player#streaming-library)

  1. npm i @distube/ytdl-core@latest
  2. Set DP_FORCE_YTDL_MOD="@distube/ytdl-core" environment variable

This should make your bot play youtube stream smoothly and play live stream normally

We support the following youtube streaming libs:

If ytdl-core is not working, try another lib (process.env.DP_FORCE_YTDL_MOD supports all of these libs).