8
8
import shutil
9
9
import ffmpy
10
10
11
+
11
12
# functions
12
13
13
14
@@ -21,23 +22,23 @@ def download_1file_MP4():
21
22
# get user path
22
23
get_link = link_field .get ()
23
24
# get selected path
24
- user_path = path_label .cget ("text" )
25
+ download_directory = path_label .cget ("text" )
25
26
# Download video
26
27
screen .title ('Downloading ...' )
27
28
mp4_video = YouTube (get_link ).streams .get_highest_resolution ().download ()
28
29
vid_clip = VideoFileClip (mp4_video )
29
30
vid_clip .close ()
30
- shutil .move (mp4_video , user_path )
31
+ shutil .move (mp4_video , download_directory )
31
32
screen .title ('Download complete! Download another file ..?' )
32
33
33
34
34
35
# download whole playlist in MP3 audio
35
36
def download_playlist_MP4 ():
36
37
print ('Downloading playlist MP4 ...' )
37
- screen .title ('started downloading playlist ...' )
38
+ screen .title ('started downloading playlist in MP4 ...' )
38
39
playlist_link = link_field .get ()
39
40
# get user path
40
- user_directory = path_label .cget ('text' )
41
+ download_directory = path_label .cget ('text' )
41
42
playlist = Playlist (playlist_link )
42
43
# looping through each video
43
44
for video in playlist .videos :
@@ -47,12 +48,34 @@ def download_playlist_MP4():
47
48
video .streams .\
48
49
filter (only_audio = True ).\
49
50
first ().\
50
- download (user_directory )
51
+ download (download_directory )
51
52
print ('finished downloading!' )
52
53
53
54
54
55
def download_playlist_MP3 ():
55
- print ('Downloading playlist MP3 ...' )
56
+ screen .title ('started downloading playlist in MP3' )
57
+ playlist_link = link_field .get ()
58
+
59
+ playlist = Playlist (playlist_link )
60
+ download_directory = path_label .cget ('text' )
61
+
62
+ for video in playlist .videos :
63
+ print ('Downloading playlist MP3 ...' )
64
+ audio = video .streams .get_audio_only ()
65
+ audio .download (download_directory )
66
+
67
+ video_title = video .title
68
+
69
+ new_filename = video_title + '.mp3'
70
+ default_filename = video_title + '.mp4'
71
+
72
+ print ('from' + default_filename + 'to' + new_filename )
73
+ ff = ffmpy .FFmpeg (
74
+ inputs = {default_filename : None },
75
+ outputs = {new_filename : None }
76
+ )
77
+
78
+ ff .run ()
56
79
57
80
58
81
# styling
0 commit comments