vinissh

Untitled

Oct 22nd, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/bin/env python
  2. # Requires: youtube_dl module
  3. # Requires: ffmpeg
  4. # Usage:
  5. #
  6. # python youtube2mp3.py <URL>, ...
  7. #
  8. # Example:
  9. #
  10. # python youtube2mp3.py https://www.youtube.com/watch?v=dQw4w9WgXcQ
  11.  
  12. import youtube_dl
  13. import sys
  14.  
  15.  
  16. ydl_opts = {
  17.     'format': 'bestaudio/best',
  18.     'postprocessors': [{
  19.         'key': 'FFmpegExtractAudio',
  20.         'preferredcodec': 'mp3',
  21.         'preferredquality': '192',
  22.     }],
  23. }
  24.  
  25.  
  26. if __name__ == "__main__":
  27.     with youtube_dl.YoutubeDL(ydl_opts) as ydl:
  28.         filenames = sys.argv[1:]
  29.         ydl.download(filenames)
Advertisement
Add Comment
Please, Sign In to add comment