|
10 | 10 | # videoURL = str(input("Enter Video Link : ")) |
11 | 11 | videoURL = 'https://www.youtube.com/watch?v=HE7ViC-n25g' |
12 | 12 |
|
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: |
14 | 20 | vidInfo = ydl.extract_info(videoURL, download=False) |
15 | 21 |
|
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.") |
19 | 75 |
|
| 76 | +# # Download the chosen format |
| 77 | +# ydl = YoutubeDL({'format': info['formats'][usrChosenFormat]['format_id']}) |
| 78 | +# ydl.download([ytlink]) |
20 | 79 |
|
0 commit comments