|
1 | 1 | from pytube import YouTube |
2 | | -import pathlib |
| 2 | +import os |
| 3 | +from modules import vidmerge |
3 | 4 |
|
4 | 5 |
|
5 | 6 | print(f"===============================\n Python YouTube Downloader v2.0\n===============================\n") |
|
10 | 11 |
|
11 | 12 | yt = YouTube(videoURL) |
12 | 13 |
|
| 14 | +mediaPath = f"{os.getcwd()}/vids" |
13 | 15 |
|
14 | | -print("-------VIDEOS-------") |
15 | | - |
| 16 | +# print("-------VIDEOS-------") |
16 | 17 | for count, stream in enumerate(yt.streams.filter(only_video=True, mime_type="video/mp4"), start=1): |
17 | 18 | print(f"{count}) Res: {stream.resolution} | Size:{stream.filesize_mb} mb") |
18 | 19 | # print(stream) |
19 | 20 |
|
20 | 21 | userInput = input(str("Enter Res: ")) |
21 | 22 |
|
22 | 23 | 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 | + stream.download(filename=f"{yt.title}.mp4", output_path=mediaPath) |
24 | 25 | print(userInput, ": MP4 Downloaded.✔") |
25 | 26 |
|
26 | 27 |
|
27 | 28 |
|
28 | | -print("-------AUDIOS-------") |
29 | | - |
| 29 | +# print("-------AUDIOS-------") |
30 | 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") |
| 31 | + stream.download(filename=f"{yt.title}.mp3", output_path=mediaPath) |
32 | 32 | print(stream.abr,": MP3 Downloaded. ✔") |
33 | 33 |
|
34 | | - |
35 | | - |
36 | 34 |
|
| 35 | +# Merge the Audio & Video File |
| 36 | +vidmerge.merge(title=yt.title) |
37 | 37 |
|
| 38 | +# Remove Seperate Media Files |
| 39 | +os.remove(f"{mediaPath}/{yt.title}.mp4") |
| 40 | +os.remove(f"{mediaPath}/{yt.title}.mp3") |
38 | 41 |
|
39 | 42 |
|
40 | 43 |
|
|
0 commit comments