Skip to content

Instantly share code, notes, and snippets.

@vishalbandre
Created November 29, 2022 03:55
Show Gist options
  • Save vishalbandre/ad090798d6c238334ad5a77afd81c78f to your computer and use it in GitHub Desktop.
Save vishalbandre/ad090798d6c238334ad5a77afd81c78f to your computer and use it in GitHub Desktop.
# Download YouTube video as MP3
import subprocess
def download_youtube_video_as_mp3(url, output_file):
cmd = 'youtube-dl -x --audio-format mp3 ' + url + ' -o ' + output_file
subprocess.call(cmd, shell=True)
download_youtube_video_as_mp3('https://www.youtube.com/watch?v=srVPLrmlBJY', 'output.mp3')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment