2017-11-08 09:57:22 -05:00
|
|
|
# This reports the stream count
|
2019-02-06 19:40:54 -05:00
|
|
|
#!/usr/bin/env python
|
2017-11-08 09:57:22 -05:00
|
|
|
|
|
|
|
import json
|
|
|
|
import requests
|
|
|
|
import math
|
|
|
|
|
2019-02-06 19:40:54 -05:00
|
|
|
f = open("/home/hass/.homeassistant/python_scripts/plexpy/.creds", "r")
|
|
|
|
data = f.read().splitlines()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
host = data[4]
|
|
|
|
api_key = data[5]
|
|
|
|
url_base = data[6]
|
|
|
|
ssl = data[7]
|
2017-11-08 09:57:22 -05:00
|
|
|
|
|
|
|
if ssl == 'true':
|
|
|
|
http = 'https'
|
|
|
|
if ssl == 'false':
|
|
|
|
http = 'http'
|
|
|
|
|
|
|
|
url = http + "://" + host + "/" + url_base + "/api/v2?apikey=" + api_key + "&cmd=get_activity"
|
|
|
|
|
2019-02-06 19:40:54 -05:00
|
|
|
response = requests.get(url)
|
2017-11-08 09:57:22 -05:00
|
|
|
|
|
|
|
json_input = response.text
|
|
|
|
|
|
|
|
decoded = json.loads(json_input)
|
|
|
|
|
|
|
|
stream_count = decoded['response']['data']['stream_count']
|
|
|
|
stream_count = int(stream_count)
|
|
|
|
stream_audio_bitrate_total = 0
|
|
|
|
stream_video_bitrate_total = 0
|
|
|
|
stream_bitrate_total = 0
|
|
|
|
print(stream_count)
|