added volume control

This commit is contained in:
aj 2019-05-07 23:16:04 +01:00
parent 0c5729d7c5
commit 707404a248
3 changed files with 18 additions and 2 deletions

View File

@ -26,4 +26,5 @@ if __name__ == '__main__':
network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME'])) network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
network.setShuffle(True) network.setShuffle(True)
network.setVolume(os.environ['SPOTALARMVOLUME'])
network.next() network.next()

View File

@ -9,4 +9,6 @@ if __name__ == '__main__':
#network.getPlaylist('000Eh2vXzYGgrEFlgcWZj3') #network.getPlaylist('000Eh2vXzYGgrEFlgcWZj3')
network.getPlayer() #network.getPlayer()
network.setVolume(30)

View File

@ -149,7 +149,6 @@ class network:
print(req.status_code) print(req.status_code)
print(req.text) print(req.text)
def setShuffle(self, state, deviceid=None): def setShuffle(self, state, deviceid=None):
headers = {'Authorization': 'Bearer ' + self.user.access_token} headers = {'Authorization': 'Bearer ' + self.user.access_token}
@ -163,3 +162,17 @@ class network:
print(req.status_code) print(req.status_code)
print(req.text) print(req.text)
def setVolume(self, volume, deviceid=None):
headers = {'Authorization': 'Bearer ' + self.user.access_token}
params = {'volume_percent': volume}
if deviceid is not None:
params['device_id'] = deviceid
req = requests.put(const.api_url + 'me/player/volume', params=params, headers=headers)
print(req.status_code)
print(req.text)