added shuffle and next to alarm, next and shuffle to network

This commit is contained in:
aj 2019-04-30 23:16:54 +01:00
parent 08a07800dc
commit deb35fe160
2 changed files with 32 additions and 0 deletions

View File

@ -7,3 +7,6 @@ if __name__ == '__main__':
network = networkclass.network(userclass.User()) network = networkclass.network(userclass.User())
network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME'])) network.play(os.environ['SPOTALARMURI'], network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
network.setShuffle(True)
network.next()

View File

@ -134,3 +134,32 @@ class network:
print(req.status_code) print(req.status_code)
print(req.text) print(req.text)
def next(self, deviceid=None):
headers = {'Authorization': 'Bearer ' + self.user.access_token}
if deviceid is not None:
params = {'device_id': deviceid}
else:
params = None
req = requests.post(const.api_url + 'me/player/next', params=params, headers=headers)
print(req.status_code)
print(req.text)
def setShuffle(self, state, deviceid=None):
headers = {'Authorization': 'Bearer ' + self.user.access_token}
params = {'state': str(state).lower()}
if deviceid is not None:
params['device_id'] = deviceid
req = requests.put(const.api_url + 'me/player/shuffle', params=params, headers=headers)
print(req.status_code)
print(req.text)