Skip to content

Commit fd3e10a

Browse files
committed
Download Audio & Video Seperately.
1 parent 41f622a commit fd3e10a

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,8 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
160+
#.idea/
161+
162+
.mp4
163+
.mp3
164+
/vids

downloader.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
from pytube import YouTube
2+
import pathlib
23

34

4-
print(f" ==========================\n Python YouTube Downloader \n==========================\n")
5+
print(f"===============================\n Python YouTube Downloader v2.0\n===============================\n")
56

67
# 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+
911
yt = YouTube(videoURL)
10-
print(yt.title)
1112

12-
# print("Fetching the info...")
1313

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: "))
1721

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.✔")
2125

22-
# print("\nDownloading...")
2326

2427

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+
2536

26-
# print("Downloaded Successfully! \n ")
2737

2838

2939

0 commit comments

Comments
 (0)