MCPcopy
hub / github.com/blacktwin/JBOPS / _call_api

Method _call_api

reporting/weekly_stats_reporting.py:301–326  ·  view source on GitHub ↗
(self, cmd, payload, method='GET')

Source from the content-addressed store, hash-verified

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
329class Notification(object):

Callers 5

get_librariesMethod · 0.95
get_home_statsMethod · 0.95
get_historyMethod · 0.95
notifyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected