Created
November 6, 2023 14:19
-
-
Save kevin-weitgenant/1378e053f5e6856feb9367bc47f159a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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