VideoDubber / ytdownloader.py
Suparnpreet's picture
Upload 7 files
2c1eba3 verified
raw
history blame
569 Bytes
# import subprocess
# subprocess.run("pip install pytube", shell=True)
from pytube import YouTube
def download_youtube_video(url, output_path):
try:
# Create a YouTube object
yt = YouTube(url)
# Get the highest resolution stream available
stream = yt.streams.get_highest_resolution()
# Download the video
stream.download(output_path=output_path)
print(f"Video downloaded successfully and saved to {output_path}")
except Exception as e:
print(f"An error occurred: {e}")