SHARE
TWEET

Untitled

a guest Mar 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from youtube_dl import YoutubeDL
  2.  
  3. ydl_opts = {
  4.    "format": "bestaudio/best",
  5.    "postprocessors": [{
  6.       "key": "FFmpegExtractAudio",
  7.       "preferredcodec": "mp3",
  8.       "preferredquality": "192" }],
  9.    "outtmpl": "%(title)s.%(etx)s",
  10.    "quiet": False }
  11. before_options = "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
  12.  
  13. # define voice_client (discord.VoiceClient) and url (String) variables here
  14.  
  15. with YoutubeDL(ydl_opts) as ydl:
  16.    song_info = ydl.extract_info(url, download=False)
  17.    raw_url = song_info["formats"][0]["url"]
  18. audio = discord.FFmpegPCMAudio(raw_url, before_options=before_options)
  19. voice_client.play(audio)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top