From fff4a5c7936dfb80d8ac076467e48df206387d61 Mon Sep 17 00:00:00 2001 From: 12nick12 Date: Tue, 10 Oct 2017 16:26:06 -0400 Subject: [PATCH] First test python file My first test python file to start the project since this will be my first dwelling into python --- plexpy.test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plexpy.test.py diff --git a/plexpy.test.py b/plexpy.test.py new file mode 100644 index 0000000..36e8613 --- /dev/null +++ b/plexpy.test.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import requests + +host = 'host.site' +api_key = 'api_key_from_plexpy' +url_base = 'url_base_with_beginning_slash_leave_blank_if_nothin' +ssl = 'true_or_false_for_ssl' + +if ssl == 'true': + http = 'https' +if ssl == 'false': + http = 'http' + +url = http + "://" + host + url_base + "/api/v2?apikey=" + api_key + "&cmd=get_activity" + +requests.packages.urllib3.disable_warnings() + +response = requests.get(url, verify=False) + +json_input = response.text + +decoded = json.loads(json_input) + +stream_count = decoded['response']['data']['stream_count'] +stream_count = int(stream_count) + +print(stream_count)