-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtui.py
55 lines (45 loc) · 1.43 KB
/
tui.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
from mixer import Mixer
import os
class Tui:
def __init__(self, path):
self.files = []
self.path = path
for file in os.listdir(self.path):
if file.endswith(".mp3"):
self.files.append(file)
self.mixer = Mixer(path)
self.menu = {
'1': self.add,
'2': self.mixer.mix,
'3': exit
}
def show_menu(self):
print('''
1. Добавить трек
2. Смешать треки
3. Выход
''')
def add(self):
print('Выберите трек')
self.printListFiles()
choice = int(input('Выберите трек: '))
file = self.files[choice]
start = int(input('Введите начало трека: '))
end = int(input('Введите конец трека: '))
self.mixer.cut(file, start, end)
print('Трек добавлен')
def printListFiles(self):
for idx, file in enumerate(self.files):
print('===[' + str(idx) + ']', file)
def run(self):
while True:
self.show_menu()
choice = input('Выберите пункт меню: ')
action = self.menu.get(choice)
if action:
action()
else:
print('Неверный пункт меню')
if __name__ == '__main__':
tui = Tui('music/')
tui.run()