-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
35 lines (30 loc) · 1.16 KB
/
player.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
from concurrent.futures import Future
from music_player import MusicTerminal
def prompt():
player = MusicTerminal(video=False, prefix='/')
username = input(" User : ")
future = None
try:
saved_playlist = player.playlist(username, "get")()
if saved_playlist is not None:
choice = input(" Wanna listen saved playlist [Y/n] ").lower()
if choice == "y":
future = player.addViaDB(saved_playlist)
del saved_playlist
except Exception as err:
print(err.args[0])
user_input = ''
print(f' Use Prefix before command : /command args')
try:
while user_input != "no" and not player.core_shutdown():
user_input = input(f"[{player.playing_msg}] [Add|Repeat|Terminate|playlist set/get] : ").lower()
# only one function will return smth, and it's `add_song`
# so, we only need to create a var. `future`
temp = player.process_command(user_input)
if isinstance(temp, Future):
future = temp
del temp
except KeyboardInterrupt:
return player, future
finally:
return player, future