Created
November 15, 2022 10:25
-
-
Save reuniware/f2d789db8e95e134f7610c81714ac63c to your computer and use it in GitHub Desktop.
Download Youtube Video as MP3
This file contains hidden or 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
from pytube import YouTube | |
import os | |
yt = YouTube('https://www.youtube.com/watch?v=PEnwXYJcSZc') | |
#yt.streams.get_audio_only().download() | |
video = yt.streams.filter(only_audio=True).first() | |
destination = '.' | |
out_file = video.download(output_path=destination) | |
base, ext = os.path.splitext(out_file) | |
new_file = base + '.mp3' | |
os.rename(out_file, new_file) | |
# result of success | |
print(yt.title + " has been successfully downloaded.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment