Created
September 10, 2023 18:27
-
-
Save NataliaItani/7e0d2b2372c63c91e9acbb8520045412 to your computer and use it in GitHub Desktop.
Youtube Downloader
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
import pytube | |
def download_video(url, save_path): | |
try: | |
# Create a YouTube object | |
yt = pytube.YouTube(url) | |
# Get the highest resolution stream | |
stream = yt.streams.get_highest_resolution() | |
# Download the video | |
stream.download(output_path=save_path) | |
print("Download completed successfully.") | |
except Exception as e: | |
print(f"An error occurred: {e}") | |
if __name__ == "__main__": | |
video_url = input("Enter the YouTube video URL: ") | |
save_location = input("Enter the directory to save the video: ") | |
download_video(video_url, save_location) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome