Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/env python
- # Requires: youtube_dl module
- # Requires: ffmpeg
- # Usage:
- #
- # python youtube2mp3.py <URL>, ...
- #
- # Example:
- #
- # python youtube2mp3.py https://www.youtube.com/watch?v=dQw4w9WgXcQ
- import youtube_dl
- import sys
- ydl_opts = {
- 'format': 'bestaudio/best',
- 'postprocessors': [{
- 'key': 'FFmpegExtractAudio',
- 'preferredcodec': 'mp3',
- 'preferredquality': '192',
- }],
- }
- if __name__ == "__main__":
- with youtube_dl.YoutubeDL(ydl_opts) as ydl:
- filenames = sys.argv[1:]
- ydl.download(filenames)
Advertisement
Add Comment
Please, Sign In to add comment