-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyputubecorrect.py
36 lines (23 loc) · 897 Bytes
/
yputubecorrect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Projet "Youtube Downloader"
# Jonathan Roux : CodeAvecJonathan
# https://codeavecjonathan.com
# module : pytube
from pytube import YouTube
url = "https://www.youtube.com/watch?v=9bZkp7q19f0"
def on_download_progress(stream, chunk, bytes_remaining):
bytes_downloaded = stream.filesize - bytes_remaining
percent = bytes_downloaded * 100 / stream.filesize
print(f"Progression du téléchargement {int(percent)}%")
youtube_video = YouTube(url)
youtube_video.register_on_progress_callback(on_download_progress)
print("TITRE: " + youtube_video.title)
print("NB VUES:", youtube_video.views)
print("STREAMS")
for stream in youtube_video.streams.fmt_streams:
print(" ", stream)
# stream = youtube_video.streams.get_by_itag(18)
stream = youtube_video.streams.get_highest_resolution()
print("Steam vidéo: ", stream)
print("Téléchargement...")
stream.download()
print("OK")