Skip to content

Commit 037afd0

Browse files
committed
Show format of the YT video & download options.
1 parent fa311fd commit 037afd0

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed
Binary file not shown.

downloader.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,70 @@
1010
# videoURL = str(input("Enter Video Link : "))
1111
videoURL = 'https://www.youtube.com/watch?v=HE7ViC-n25g'
1212

13-
with YoutubeDL() as ydl:
13+
ydl_opts = {
14+
"quiet": True,
15+
'outtmpl': "%(title)s_%(id)s.%(ext)s"
16+
}
17+
18+
19+
with YoutubeDL( ydl_opts ) as ydl:
1420
vidInfo = ydl.extract_info(videoURL, download=False)
1521

16-
print("\n- Title 👉", vidInfo.get('title', None))
17-
print("- Views 👉", vidInfo.get('view_count', None), "views")
18-
print("- Thubnail 👉", vidInfo.get('thumbnail', None))
22+
print("\n🔹 Title:", vidInfo.get('title', None))
23+
print("🔹 Views:", vidInfo.get('view_count', None), "views")
24+
print("🔹 Size:", vidInfo.get('filesize', None))
25+
26+
print("\n CHOOSE YOUR RESOLUTION \n--------------------------")
27+
28+
for format in vidInfo['formats']:
29+
print(f"{format['format_id']} - {format['format']} - {format['ext']}")
30+
31+
32+
33+
34+
35+
36+
37+
# from yt_dlp import YoutubeDL
38+
39+
# ydl = YoutubeDL({'listformats': True})
40+
# ytlink = "https://www.youtube.com/watch?v=HE7ViC-n25g"
41+
# info = ydl.extract_info(ytlink, download=False)
42+
43+
44+
45+
# for format in info['formats']:
46+
# print(f"{format['format_id']} - {format['format']} - {format['ext']}")
47+
48+
# usrChosenFormat = str(input("Choose Format: "))
49+
50+
# ydl = YoutubeDL({'format': usrChosenFormat})
51+
# ydl.download([ytlink])
52+
53+
#give a specific no to each specific format, so i can choose them in the userChosenFormat and download the exact format i want. also make the output more organized for better user experience.
54+
55+
56+
# from yt_dlp import YoutubeDL
57+
58+
# ydl = YoutubeDL()
59+
# ytlink = "https://www.youtube.com/watch?v=HE7ViC-n25g"
60+
# info = ydl.extract_info(ytlink, download=False)
61+
62+
# # Print out a numbered list of available formats
63+
# for i, format in enumerate(info['formats']):
64+
# print(f"{i+1}. {format['format_id']} - {format['format']} - {format['ext']}")
65+
66+
# # Get user input and validate it
67+
# while True:
68+
# try:
69+
# usrChosenFormat = int(input("Choose Format: ")) - 1
70+
# if usrChosenFormat < 0 or usrChosenFormat >= len(info['formats']):
71+
# raise ValueError()
72+
# break
73+
# except ValueError:
74+
# print("Invalid input. Please enter a number corresponding to a format.")
1975

76+
# # Download the chosen format
77+
# ydl = YoutubeDL({'format': info['formats'][usrChosenFormat]['format_id']})
78+
# ydl.download([ytlink])
2079

0 commit comments

Comments
 (0)