diff --git a/alarm.py b/alarm.py index 583c300..41a4e66 100644 --- a/alarm.py +++ b/alarm.py @@ -26,4 +26,5 @@ if __name__ == '__main__': network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME'])) network.setShuffle(True) + network.setVolume(os.environ['SPOTALARMVOLUME']) network.next() diff --git a/main.py b/main.py index 8229ecc..707b565 100644 --- a/main.py +++ b/main.py @@ -9,4 +9,6 @@ if __name__ == '__main__': #network.getPlaylist('000Eh2vXzYGgrEFlgcWZj3') - network.getPlayer() + #network.getPlayer() + + network.setVolume(30) \ No newline at end of file diff --git a/spotframework/net/network.py b/spotframework/net/network.py index 6371bdc..f3f462b 100644 --- a/spotframework/net/network.py +++ b/spotframework/net/network.py @@ -149,7 +149,6 @@ class network: print(req.status_code) print(req.text) - def setShuffle(self, state, deviceid=None): headers = {'Authorization': 'Bearer ' + self.user.access_token} @@ -163,3 +162,17 @@ class network: print(req.status_code) 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)