-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify.py
executable file
·38 lines (31 loc) · 1023 Bytes
/
spotify.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
import urwid
import sys
from repository import scopes
from repository.auth import authorize_session
# Print debug to file that can be followed with $ tail
# sys.stdout = open('stdout', 'w')
from pydux.create_store import create_store
from urwid_pydux import subscribe_urwid_redraw
from actions import get_main_menu, get_current_song
from misc import get_configs
from components.App import App
from reducers import spotter_app
def open_app():
store = create_store(spotter_app)
store.dispatch(get_current_song())
store.dispatch(get_main_menu())
root = App(store=store)
loop = urwid.MainLoop(root)
subscribe_urwid_redraw(store, loop)
loop.run()
def get_scopes():
return [getattr(scopes, prop) for prop in dir(scopes) if "__" not in prop]
def authorize_user(username):
scopes = get_scopes()
authorize_session(username, " ".join(scopes))
def main():
config = get_configs()
authorize_user(config.get('spotify_username'))
open_app()
if __name__ == '__main__':
main()