-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjukebox.py
More file actions
42 lines (28 loc) · 811 Bytes
/
jukebox.py
File metadata and controls
42 lines (28 loc) · 811 Bytes
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
import spotify
import threading
from jukebox_manager import JukeboxManager
from webserver import Server
from credentials import *
logged_in_event = threading.Event()
def connection_state_listener(session):
if session.connection.state is spotify.ConnectionState.LOGGED_IN:
logged_in_event.set()
session = spotify.Session()
loop = spotify.EventLoop(session)
loop.start()
session.on(
spotify.SessionEvent.CONNECTION_STATE_UPDATED,
connection_state_listener)
print "Logging in..."
session.login( username, passwd)
logged_in_event.wait()
if session.connection.state == 1:
print "Logged in!"
jukebox = JukeboxManager(session)
server = Server(jukebox)
server.start()
jukebox.set_playlist( playlist_uri)
jukebox.set_queue( queue_uri )
jukebox.set_server(server)
jukebox.list_tracks()
jukebox.run()