Created
October 18, 2022 07:08
-
-
Save miguelvb/b132b365c60fe7d22ac532045650e3a1 to your computer and use it in GitHub Desktop.
Youtube download python
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
# TAKEN FROM https://dev.to/stokry/download-youtube-video-to-mp3-with-python-26p | |
# run first pip3 install youtube_dl in your env... | |
import youtube_dl | |
def run(): | |
video_url = input("please enter youtube video url:") | |
video_info = youtube_dl.YoutubeDL().extract_info( | |
url = video_url,download=False | |
) | |
filename = f"{video_info['title']}.mp3" | |
options={ | |
'format':'bestaudio/best', | |
'keepvideo':False, | |
'outtmpl':filename, | |
} | |
with youtube_dl.YoutubeDL(options) as ydl: | |
ydl.download([video_info['webpage_url']]) | |
print("Download complete... {}".format(filename)) | |
if __name__=='__main__': | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment