|
1 | 1 | from pytube import YouTube |
| 2 | +import pathlib |
2 | 3 |
|
3 | 4 |
|
4 | | -print(f" ==========================\n Python YouTube Downloader \n==========================\n") |
| 5 | +print(f"===============================\n Python YouTube Downloader v2.0\n===============================\n") |
5 | 6 |
|
6 | 7 | # videoURL = str(input("Enter Video Link : ")) |
7 | | -videoURL = 'https://www.youtube.com/watch?v=5cCaU6T1yFE' |
8 | | - |
| 8 | +videoURL = 'https://www.youtube.com/watch?v=mDTMBdYAjHI' |
| 9 | +# https://youtu.be/krsBRQbOPQ4?si=UKY-g36vKVM7Umqc : MrBeast Video |
| 10 | + |
9 | 11 | yt = YouTube(videoURL) |
10 | | -print(yt.title) |
11 | 12 |
|
12 | | -# print("Fetching the info...") |
13 | 13 |
|
14 | | - # vidTitle = |
15 | | - # vidDuration = |
16 | | - # vidSize = |
| 14 | +print("-------VIDEOS-------") |
| 15 | + |
| 16 | +for count, stream in enumerate(yt.streams.filter(only_video=True, mime_type="video/mp4"), start=1): |
| 17 | + print(f"{count}) Res: {stream.resolution} | Size:{stream.filesize_mb} mb") |
| 18 | + # print(stream) |
| 19 | + |
| 20 | +userInput = input(str("Enter Res: ")) |
17 | 21 |
|
18 | | - # print("\n= Title:", vidTitle) |
19 | | - # print("= Duration:", vidDuration) |
20 | | - # print("= Size:", vidSize , "MB") |
| 22 | +for stream in yt.streams.filter(only_video=True, mime_type="video/mp4", res=userInput): |
| 23 | + stream.download(filename=f"{yt.title}.mp4", output_path=f"{pathlib.Path(__file__).parent.resolve()}/vids") |
| 24 | + print(userInput, ": MP4 Downloaded.✔") |
21 | 25 |
|
22 | | -# print("\nDownloading...") |
23 | 26 |
|
24 | 27 |
|
| 28 | +print("-------AUDIOS-------") |
| 29 | + |
| 30 | +for stream in yt.streams.filter(only_audio=True, abr="128kbps"): |
| 31 | + stream.download(filename=f"{yt.title}.mp3", output_path=f"{pathlib.Path(__file__).parent.resolve()}/vids") |
| 32 | + print(stream.abr,": MP3 Downloaded. ✔") |
| 33 | + |
| 34 | + |
| 35 | + |
25 | 36 |
|
26 | | -# print("Downloaded Successfully! \n ") |
27 | 37 |
|
28 | 38 |
|
29 | 39 |
|
|
0 commit comments