1from pytube import YouTube
2import os
3from pathlib import Path
4
5link = input("Enter link here: ")
6
7url = YouTube(link)
8
9print("downloading....")
10
11video = url.streams.get_highest_resolution()
12
13path_to_download_folder = str(os.path.join(Path.home(), "Downloads"))
14
15video.download(path_to_download_folder)
16print("Downloaded! :)")
1 from pytube import Playlist
2 pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU")
3 for video in pl.videos:
4 video.streams.first().download()
5
1 from pytube import Playlist
2 ps = Playlist("https://www.youtube.com/watch?v=R6wQmWMDiB4&list=PLYmlEoSHldN4nV-Js4x7domjygiBkeatC")
3 for video in ps.videos:
4 video.streams.first().download()
1>>> from pytube import YouTube
2>>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
3>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
4>>> yt.streams
5... .filter(progressive=True, file_extension='mp4')
6... .order_by('resolution')
7... .desc()
8... .first()
9... .download()
10