fixed time

This commit is contained in:
Nicholas St. Germain 2018-12-01 17:11:46 -06:00
parent 7638cd937e
commit 98677892e2
2 changed files with 7 additions and 2 deletions

View file

@ -24,6 +24,7 @@ class SonarrAPI(object):
def get_missing(self, days_past):
endpoint = '/api/calendar'
last_days = str(date.today() + timedelta(days=-days_past))
self.now = datetime.now(timezone.utc).astimezone().isoformat()
params = {'start': last_days, 'end': self.today}
influx_payload = []
@ -66,6 +67,7 @@ class SonarrAPI(object):
@logging
def get_future(self, future_days):
endpoint = '/api/calendar/'
self.now = datetime.now(timezone.utc).astimezone().isoformat()
future = str(date.today() + timedelta(days=future_days))
influx_payload = []
@ -109,6 +111,7 @@ class SonarrAPI(object):
def get_queue(self, notimplemented):
influx_payload = []
endpoint = '/api/queue'
self.now = datetime.now(timezone.utc).astimezone().isoformat()
for server in self.servers:
queue = []

View file

@ -5,12 +5,13 @@ import requests
from Varken.helpers import TautulliStream, geo_lookup
from Varken.logger import logging
class TautulliAPI(object):
def __init__(self, servers, influx_server):
# Set Time of initialization
self.now = datetime.now(timezone.utc).astimezone().isoformat()
self.influx = InfluxDBClient(influx_server.url, influx_server.port, influx_server.username,
influx_server.password, 'plex')
influx_server.password, 'plex2')
self.servers = servers
self.session = requests.Session()
self.endpoint = '/api/v2'
@ -21,6 +22,7 @@ class TautulliAPI(object):
@logging
def get_activity(self, notimplemented):
self.now = datetime.now(timezone.utc).astimezone().isoformat()
params = {'cmd': 'get_activity'}
influx_payload = []
@ -53,6 +55,7 @@ class TautulliAPI(object):
@logging
def get_sessions(self, notimplemented):
self.now = datetime.now(timezone.utc).astimezone().isoformat()
params = {'cmd': 'get_activity'}
influx_payload = []
@ -60,7 +63,6 @@ class TautulliAPI(object):
params['apikey'] = server.apikey
g = self.session.get(server.url + self.endpoint, params=params, verify=server.verify_ssl)
get = g.json()['response']['data']['sessions']
print(get)
sessions = [TautulliStream(**session) for session in get]
for session in sessions: