-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (31 loc) · 1008 Bytes
/
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
import os
import spotipy
from aiohttp import web
from dotenv import load_dotenv
from spotipy import SpotifyOAuth
from src.handlers import *
from src.chooser import chooser
from src.middleware import *
if __name__ == '__main__':
load_dotenv()
spotify_api = spotipy.Spotify(
auth_manager=SpotifyOAuth(
client_id=os.environ['SPOTIFY_CLIENT_ID'],
client_secret=os.environ['SPOTIFY_CLIENT_SECRET'],
redirect_uri=os.environ['SPOTIFY_REDIRECT_URI'],
scope='streaming app-remote-control user-read-currently-playing user-read-playback-state',
open_browser=False,
)
)
spotify_api.me()
app = web.Application(
middlewares=[
content_type_middleware,
available_device_middleware,
]
)
app['spotify_api'] = spotify_api
app.add_routes(
[web.post(os.environ['SKILL_URL_PATH'], chooser.do_route)]
)
web.run_app(app=app)