Skip to content

Commit 41f622a

Browse files
committed
Recreating the V2 With PyTube
1 parent 2ae7655 commit 41f622a

File tree

1 file changed

+15
-35
lines changed

1 file changed

+15
-35
lines changed

downloader.py

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,29 @@
1-
from yt_dlp import YoutubeDL
1+
from pytube import YouTube
22

33

44
print(f" ==========================\n Python YouTube Downloader \n​==========================\n")
55

6-
videoURL = str(input("Enter Video Link : "))
7-
# videoURL = 'https://www.youtube.com/watch?v=5cCaU6T1yFE'
8-
9-
# Progress bar shows when a video is downloading
10-
def download_loading_bar(d):
11-
if d['status'] == 'downloading':
12-
# Get the download percentage as a float
13-
percentage = float(d['_percent_str'].replace('%', ''))
14-
# Calculate how many # symbols to print
15-
num_symbols = int(percentage / 5)
16-
# Print the loading bar with the percentage and ETA, using \r and end=''
17-
print(f"\rLoading: [{'#' * num_symbols}{'-' * (20 - num_symbols)}] {d['_percent_str']} {d['_eta_str']}", end='')
18-
19-
20-
ydl_opts = {
21-
"quiet": True,
22-
'outtmpl': "%(title)s_%(id)s.%(ext)s",
23-
# "format": "bestvideo+bestaudio/best",
24-
25-
'progress_hooks': [download_loading_bar],
26-
'no_color': True,
27-
}
6+
# videoURL = str(input("Enter Video Link : "))
7+
videoURL = 'https://www.youtube.com/watch?v=5cCaU6T1yFE'
8+
9+
yt = YouTube(videoURL)
10+
print(yt.title)
2811

29-
print("Fetching the info...")
12+
# print("Fetching the info...")
3013

31-
with YoutubeDL( ydl_opts ) as ydl:
32-
vidInfo = ydl.extract_info(videoURL, download=False)
14+
# vidTitle =
15+
# vidDuration =
16+
# vidSize =
3317

34-
vidTitle = vidInfo.get('title', None)
35-
vidDuration = vidInfo.get('duration', None)
36-
vidSize = vidInfo.get('filesize_approx', None) // 1048576
18+
# print("\n= Title:", vidTitle)
19+
# print("= Duration:", vidDuration)
20+
# print("= Size:", vidSize , "MB")
3721

38-
print("\n🔹 Title:", vidTitle)
39-
print("🔹 Duration:", vidDuration)
40-
print("🔹 Size:", vidSize , "MB")
22+
# print("\nDownloading...")
4123

42-
print("\nDownloading...")
4324

44-
ydl.download(['https://www.youtube.com/watch?v=BxUS1K7xu30'])
4525

46-
print("Downloaded Successfully! \n ")
26+
# print("Downloaded Successfully! \n ")
4727

4828

4929

0 commit comments

Comments
 (0)