Skip to content

Instantly share code, notes, and snippets.

@kevin-weitgenant
Created November 6, 2023 14:19
Show Gist options
  • Save kevin-weitgenant/1378e053f5e6856feb9367bc47f159a7 to your computer and use it in GitHub Desktop.
Save kevin-weitgenant/1378e053f5e6856feb9367bc47f159a7 to your computer and use it in GitHub Desktop.
import yt_dlp
def download_video_audio(url):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
# Example usage:
video_url = 'https://youtu.be/5_3wWKwvsxA?si=DqyZOiq6qV4jUqUY'
download_video_audio(video_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment