Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.71k stars 3.74k forks source link

Cannot create an youtube_dl player on rewrite #558

Closed rpyuser closed 7 years ago

rpyuser commented 7 years ago

I noticed that youtube_dl players cannot be used anymore because of the fact that the 'create_ytdl_player' function was removed. Do you have any plan to provide something to help people get the data they need for playing youtube / SoundCloud videos in voice channels including the name and duration of such videos? I would hate to hack create my own AudioSource subclass just so I can play the videos like I can do with the latest 0.16.7 version on PyPi. I just would like something to help with this need of mine for a bot I am planning to make and still working on.

ryanchesler commented 7 years ago

am interested in this as well. Just got it up and running for the first time and it does not seem to be working

SapphicCode commented 7 years ago

The point of AudioSources is exactly this: to be able to easily subclass them. Making a YTDL-based audio source shouldn't really prove that hard if you know what you're doing.

ryanchesler commented 7 years ago

looks like it wasnt removed. http://discordpy.readthedocs.io/en/latest/api.html#voice

You have to do pip install youtube_dl.

The documentation on this is all over the place.

slice commented 7 years ago

That link points to async docs, not rewrite.

Rooni commented 7 years ago

You can still get the source url through youtube_dl manually and pass it through discord.FFmpegPCMAudio().

xNinjaKittyx commented 7 years ago

Going off of Neko's comment, you can get the info of a youtube link (which includes a bunch of data, including the direct download links) using the following code (requires pip install youtube-dl obviously)

import youtube_dl

opts = {}
with youtube_dl.YoutubeDL(opts) as ydl:
    song_info = ydl.extract_info('https://www.youtube.com/watch?v=dQw4w9WgXcQ', download=False)

Then song_info will give you a huge dictionary filled with data. You'll have to play around with it yourself and find what you want out of the data you get. Then pass it in discord.FFmpegPCMAudio() like Neko said.

Rapptz commented 7 years ago

Considering there's an example that uses YTDL, I'm gonna close this.

ExeModz commented 4 years ago

fuck you

Themis3000 commented 3 years ago

For anyone who's found this thread on google still trying to figure out how this works, the example Rapptz was talking about is here: https://github.com/Rapptz/discord.py/blob/master/examples/basic_voice.py. You'll want to check out the methods yt and stream on lines 78 and 88