-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (49 loc) · 1.83 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
import eyed3
from tkinter import Tk
from tkinter.filedialog import askopenfilename
from appJar import gui
from shutil import copyfile
selected_filename = 'No file has been selected!'
def select_file():
global selected_filename
Tk().withdraw()
selected_filename = askopenfilename()
audiofile = eyed3.load(selected_filename)
app.setLabel('file', 'selected file: ' + selected_filename[::-1].split('/', 1)[0][::-1])
try:
app.setLabel('song', 'Song Name: ' + audiofile.tag.title)
except TypeError:
app.setLabel('song', 'Song Name: ????')
try:
app.setLabel('artist', 'Artist(s) Name: ' + audiofile.tag.artist)
except TypeError:
app.setLabel('artist', 'Artist(s) Name: ????')
app.enableButton('Submit')
def generate_new_name(name):
return name[::-1].split('.', 1)[1][::-1] + '(modified).' + name[::-1].split('.', 1)[0][::-1]
def change_metadata(filename):
audiofile = eyed3.load(filename)
audiofile.tag.title = app.getEntry("New Song Name:")
audiofile.tag.artist = app.getEntry("New Artist(s) Name:")
audiofile.tag.save()
def press(button):
global selected_filename
print('s')
if button == 'Submit':
if not app.check("Create a new file"):
change_metadata(selected_filename)
else:
new_file_name = generate_new_name(selected_filename)
copyfile(selected_filename, new_file_name)
change_metadata(new_file_name)
app = gui("Login Window", "400x200")
app.addButton("select", select_file)
app.addLabel("file", selected_filename)
app.addLabel("song", 'Song Name: -')
app.addLabel("artist", 'Artist(s) Name: -')
app.addLabelEntry("New Song Name:")
app.addLabelEntry("New Artist(s) Name:")
app.addCheckBox("Create a new file")
app.addButton("Submit", press)
app.disableButton('Submit')
app.go()