Spaces:
Runtime error
Runtime error
File size: 569 Bytes
2c1eba3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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}")
|