-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (48 loc) · 2.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from pytube import YouTube, Playlist
kind = int(input('For video download press 1, For playlist press 2: '))
def completedVideo():
print('Your video downloaded successfully')
def completedAudio():
print('Your audio downloaded successfully')
def highQuality():
print('Please Wait...')
video.streams.get_highest_resolution().download(output_path='c://Users/C.M/Downloads', filename=filename)
video.register_on_complete_callback(completedVideo())
def lowQuality():
print('Please Wait...')
video.streams.get_lowest_resolution().download(output_path='c://Users/C.M/Downloads', filename=filename)
video.register_on_complete_callback(completedVideo())
def audio():
print('Please Wait...')
video.streams.get_audio_only().download(output_path='c://Users/C.M/Downloads', filename=filename)
video.register_on_complete_callback(completedAudio())
if kind == 1:
url = input("Enter video_URL: ") # Link will be downloaded # https://www.youtube.com/watch?v=FxDlv1XKhD0
video = YouTube(url) # Object from YOUTUBE class
# Video Information
print("Video Title: ", video.title)
print("Video Length: ", video.length, "Seconds")
quality = int(input('for height quality press 1 for low quality press 2 for audio only press 3 '))
filename = input('Enter filename: ')
if quality == 1:
highQuality()
elif quality == 2:
lowQuality()
elif quality == 3:
audio()
elif kind == 2:
# playlist
url = input("Enter Playlist_URL: ") # Link will be downloaded # https://www.youtube.com/watch?v=1ybX_oVEbzc&list=PLMm8EjqH1EFWWKAeZFMmnbvnDML6NhY35
playlist = Playlist(url) # create object
quality = int(input('for height quality press 1 for low quality press 2 for audio only press 3 '))
folderName = input('Enter Folder name: ')
count = 0
for i in playlist.videos:
if quality == 1:
highQuality()
elif quality == 2:
lowQuality()
elif quality == 3:
audio()
count = count + 1
print('Total downloads is: ', count)