Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from youtube_dl import YoutubeDL
- ydl_opts = {
- "format": "bestaudio/best",
- "postprocessors": [{
- "key": "FFmpegExtractAudio",
- "preferredcodec": "mp3",
- "preferredquality": "192" }],
- "outtmpl": "%(title)s.%(etx)s",
- "quiet": False }
- before_options = "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
- # define voice_client (discord.VoiceClient) and url (String) variables here
- with YoutubeDL(ydl_opts) as ydl:
- song_info = ydl.extract_info(url, download=False)
- raw_url = song_info["formats"][0]["url"]
- audio = discord.FFmpegPCMAudio(raw_url, before_options=before_options)
- voice_client.play(audio)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement