(self, cmd, payload, method='GET')
| 299 | return self._call_api('notify', payload) |
| 300 | |
| 301 | def _call_api(self, cmd, payload, method='GET'): |
| 302 | payload['cmd'] = cmd |
| 303 | payload['apikey'] = self.apikey |
| 304 | |
| 305 | try: |
| 306 | response = self.session.request(method, self.url + '/api/v2', params=payload) |
| 307 | except RequestException as e: |
| 308 | print("Tautulli request failed for cmd '{}'. Invalid Tautulli URL? Error: {}".format(cmd, e)) |
| 309 | return |
| 310 | |
| 311 | try: |
| 312 | response_json = response.json() |
| 313 | except ValueError: |
| 314 | print( |
| 315 | "Failed to parse json response for Tautulli API cmd '{}': {}" |
| 316 | .format(cmd, response.content)) |
| 317 | return |
| 318 | |
| 319 | if response_json['response']['result'] == 'success': |
| 320 | if self.debug: |
| 321 | print("Successfully called Tautulli API cmd '{}'".format(cmd)) |
| 322 | return response_json['response']['data'] |
| 323 | else: |
| 324 | error_msg = response_json['response']['message'] |
| 325 | print("Tautulli API cmd '{}' failed: {}".format(cmd, error_msg)) |
| 326 | return |
| 327 | |
| 328 | |
| 329 | class Notification(object): |
no outgoing calls
no test coverage detected