-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotifyUtils.py
37 lines (24 loc) · 990 Bytes
/
spotifyUtils.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 configparser
import spotipy
from spotipy.oauth2 import SpotifyOAuth
from phue import Bridge
config = configparser.ConfigParser()
config.read('config.ini')
spotifyClientId = config['spotify']['clientId']
spotifyClientSecret = config['spotify']['clientSecret']
spotifyRedirectUri = config['spotify']['redirectUri']
spotifyScope = config['spotify']['scope']
spotifyUsername = config['spotify']['username']
hueBridgeIp = config['hue']['bridgeIp']
hueBridge = Bridge(hueBridgeIp)
hueBridge.connect()
spotify = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=spotifyClientId, client_secret=spotifyClientSecret, redirect_uri=spotifyRedirectUri, scope=spotifyScope, open_browser=False, username=spotifyUsername))
deviceList = spotify.devices()['devices']
hueGroups = hueBridge.groups
print("Your Hue groups are:")
for group in hueGroups:
print(group.name)
print()
print("Your Spotify devices are:")
for device in deviceList:
print(device['name'] + ":", device['id'])