-
Notifications
You must be signed in to change notification settings - Fork 0
/
downgui.py
68 lines (49 loc) · 2.24 KB
/
downgui.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
from tkinter import *
from tkinter import ttk
from down import *
download_succesful = False
def guiMain(*args):
songName = songNamee.get()
flag = 0
result = getAudioClip(songName)
if result != None:
url = result
video = pafy.new(url)
best = video.audiostreams
filename = video.audiostreams[0]
x=filename.download(filepath=filename.title + "." + filename.extension)
print("Converting to MP3...\n")
AudioSegment.from_file(filename.title + "." + filename.extension).export("/Users/Parth/funProjects/"+filename.title + ".mp3", format="mp3")
metaData = getMetaData(songName)
artist = metaData['artistName']
title = metaData['trackName']
if metaData['collectionName']:
album = metaData['collectionName']
else:
album = 'none'
load_image_inMP3(filename.title, artist, title, album)
print("Deleting old File...\n")
os.remove("/Users/Parth/funProjects/"+filename.title + "." + filename.extension)
os.remove("/Users/Parth/funProjects/.img.jpg")
os.rename("/Users/Parth/funProjects/"+filename.title + ".mp3","/Users/Parth/funProjects/"+title + ".mp3" )
print("Done")
download_succesful = True
root = Tk()
root.title("Music Download")
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
songNamee = StringVar()
ttk.Label(mainframe, textvariable="Enter the Song Here:").grid(column=2, row=2, sticky=(W, E))
feet_entry = ttk.Entry(mainframe, width=20, textvariable=songNamee)
feet_entry.grid(column=2, row=2, sticky=(W, E))
Button(mainframe, text="Download", command=guiMain).grid(column=3, row=3, sticky=W)
ttk.Label(mainframe, text="Enter Song Here:").grid(column=2, row=1, sticky=W)
if download_succesful:
ttk.Label(mainframe, text="Download Succesful").grid(column=1, row=3, sticky=W)
download_succesful = False
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
feet_entry.focus()
root.bind('<Return>', guiMain)
root.mainloop()