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

YouTube stream fails with could not extract stream for this track #1705

Closed
twlite opened this issue Apr 5, 2023 · 19 comments
Closed

YouTube stream fails with could not extract stream for this track #1705

twlite opened this issue Apr 5, 2023 · 19 comments
Labels
discussion ytdl-core related to node-ytdl-core

Comments

@twlite
Copy link
Collaborator

twlite commented Apr 5, 2023

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 fent/node-ytdl-core#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.

@NerdyTechy
Copy link
Contributor

@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

@twlite
Copy link
Collaborator Author

twlite commented Apr 5, 2023

@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.

@Mittelblut9
Copy link
Contributor

I have followed the workaround, but it's still failing
grafik

Song Link: https://open.spotify.com/track/1SOTqkhpIWoLX1AS9Y2RpU

@DroppedCoin375
Copy link

Downgrading to ytdl-core@4.9.1 worked for me

@twlite
Copy link
Collaborator Author

twlite commented Apr 6, 2023

I have followed the workaround, but it's still failing grafik

Song Link: https://open.spotify.com/track/1SOTqkhpIWoLX1AS9Y2RpU

Try clearing npm cache or use another package manager like yarn.

@twlite twlite changed the title YouTube stream fails YouTube stream fails with could not extract stream for this track Apr 6, 2023
@Donoso005
Copy link

Downgrade the ytdl-core package to ytdl-core@4.9.1, like that:
"ytdl-core": "4.9.1"

@fpsone
Copy link

fpsone commented Apr 6, 2023

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

@Donoso005
Copy link

How can i setup the enviroment variable, where is the variable?

@twlite
Copy link
Collaborator Author

twlite commented Apr 6, 2023

How can i setup the enviroment variable, where is the variable?

You can set it in your .env file or via cli

@khlevon
Copy link

khlevon commented Apr 6, 2023

For fix check this comment: fent/node-ytdl-core#1197 (comment)

@Donoso005
Copy link

How can i setup the enviroment variable, where is the variable?

You can set it in your .env file or via cli

And then What am I supposed to do with that variable?

1 similar comment
@Donoso005

This comment was marked as duplicate.

@twlite
Copy link
Collaborator Author

twlite commented Apr 6, 2023

And then What am I supposed to do with that variable?

You don't have to do anything with the environment variable in your code. The DP_ prefixed environment variables change the behavior of discord-player. In this case, DP_FORCE_YTDL_MOD variable makes discord-player prioritize the given ytdl module.

@bagelwastaken
Copy link

Downgrading to ytdl-core@4.9.1 worked for me

Yup, worked for me as well.

@twlite
Copy link
Collaborator Author

twlite commented Apr 14, 2023

The issue has been fixed https://github.com/fent/node-ytdl-core/releases/tag/v4.11.4

@twlite twlite closed this as completed Apr 14, 2023
@twlite twlite reopened this Apr 27, 2023
@twlite
Copy link
Collaborator Author

twlite commented Apr 27, 2023

fent/node-ytdl-core#1216

@rohankanhaisingh
Copy link

Downgrading to ytdl-core@4.9.1 worked for me

Yup, worked for me as well.

Does still work for you? For me, it doesn't. Tried everything, installing different packages, but no positive results.

@zachrussell12
Copy link

This is still an issue as of ytdl-core@4.11.4. Downgrading to 4.9.1 fixed the issue for now.

@twlite
Copy link
Collaborator Author

twlite commented Jun 12, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion ytdl-core related to node-ytdl-core
Projects
None yet
Development

No branches or pull requests

12 participants