Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement