made time local to the function. Fixes #56
This commit is contained in:
parent
7add64e48b
commit
a772ddb5a6
4 changed files with 21 additions and 28 deletions
|
@ -8,7 +8,6 @@ from varken.structures import OmbiRequestCounts
|
|||
|
||||
class OmbiAPI(object):
|
||||
def __init__(self, server, dbmanager):
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
self.dbmanager = dbmanager
|
||||
self.server = server
|
||||
# Create session to reduce server web thread load, and globally define pageSize for all requests
|
||||
|
@ -20,7 +19,7 @@ class OmbiAPI(object):
|
|||
return "<ombi-{}>".format(self.server.id)
|
||||
|
||||
def get_total_requests(self):
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
tv_endpoint = '/api/v1/Request/tv'
|
||||
movie_endpoint = "/api/v1/Request/movie"
|
||||
|
||||
|
@ -42,7 +41,7 @@ class OmbiAPI(object):
|
|||
"type": "Request_Total",
|
||||
"server": self.server.id
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"total": movie_requests + tv_requests,
|
||||
"movies": movie_requests,
|
||||
|
@ -54,7 +53,7 @@ class OmbiAPI(object):
|
|||
self.dbmanager.write_points(influx_payload)
|
||||
|
||||
def get_request_counts(self):
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
endpoint = '/api/v1/Request/count'
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + endpoint))
|
||||
|
@ -70,7 +69,7 @@ class OmbiAPI(object):
|
|||
"tags": {
|
||||
"type": "Request_Counts"
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"pending": requests.pending,
|
||||
"approved": requests.approved,
|
||||
|
|
|
@ -8,7 +8,6 @@ from varken.structures import Movie, Queue
|
|||
|
||||
class RadarrAPI(object):
|
||||
def __init__(self, server, dbmanager):
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
self.dbmanager = dbmanager
|
||||
self.server = server
|
||||
# Create session to reduce server web thread load, and globally define pageSize for all requests
|
||||
|
@ -21,7 +20,7 @@ class RadarrAPI(object):
|
|||
|
||||
def get_missing(self):
|
||||
endpoint = '/api/movie'
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
influx_payload = []
|
||||
missing = []
|
||||
|
||||
|
@ -45,10 +44,8 @@ class RadarrAPI(object):
|
|||
ma = 1
|
||||
|
||||
movie_name = '{} ({})'.format(movie.title, movie.year)
|
||||
|
||||
missing.append((movie_name, ma, movie.tmdbId, movie.titleSlug))
|
||||
|
||||
|
||||
for title, ma, mid, title_slug in missing:
|
||||
hash_id = hashit('{}{}{}'.format(self.server.id, title, mid))
|
||||
influx_payload.append(
|
||||
|
@ -62,7 +59,7 @@ class RadarrAPI(object):
|
|||
"name": title,
|
||||
"titleSlug": title_slug
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
}
|
||||
|
@ -73,7 +70,7 @@ class RadarrAPI(object):
|
|||
|
||||
def get_queue(self):
|
||||
endpoint = '/api/queue'
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
influx_payload = []
|
||||
queue = []
|
||||
|
||||
|
@ -124,7 +121,7 @@ class RadarrAPI(object):
|
|||
"protocol_id": protocol_id,
|
||||
"titleSlug": title_slug
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
}
|
||||
|
|
|
@ -8,10 +8,7 @@ from varken.structures import Queue, TVShow
|
|||
|
||||
class SonarrAPI(object):
|
||||
def __init__(self, server, dbmanager):
|
||||
# Set Time of initialization
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
self.dbmanager = dbmanager
|
||||
self.today = str(date.today())
|
||||
self.server = server
|
||||
# Create session to reduce server web thread load, and globally define pageSize for all requests
|
||||
self.session = Session()
|
||||
|
@ -24,9 +21,10 @@ class SonarrAPI(object):
|
|||
|
||||
def get_missing(self):
|
||||
endpoint = '/api/calendar'
|
||||
today = str(date.today())
|
||||
last_days = str(date.today() + timedelta(days=-self.server.missing_days))
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
params = {'start': last_days, 'end': self.today}
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
params = {'start': last_days, 'end': today}
|
||||
influx_payload = []
|
||||
missing = []
|
||||
|
||||
|
@ -63,7 +61,7 @@ class SonarrAPI(object):
|
|||
"sxe": sxe,
|
||||
"airs": air_date
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
|
||||
|
@ -75,11 +73,12 @@ class SonarrAPI(object):
|
|||
|
||||
def get_future(self):
|
||||
endpoint = '/api/calendar/'
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
today = str(date.today())
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
future = str(date.today() + timedelta(days=self.server.future_days))
|
||||
influx_payload = []
|
||||
air_days = []
|
||||
params = {'start': self.today, 'end': future}
|
||||
params = {'start': today, 'end': future}
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + endpoint, params=params))
|
||||
get = connection_handler(self.session, req, self.server.verify_ssl)
|
||||
|
@ -116,7 +115,7 @@ class SonarrAPI(object):
|
|||
"airs": air_date,
|
||||
"downloaded": dl_status
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ class SonarrAPI(object):
|
|||
def get_queue(self):
|
||||
influx_payload = []
|
||||
endpoint = '/api/queue'
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
queue = []
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + endpoint))
|
||||
|
@ -168,7 +167,7 @@ class SonarrAPI(object):
|
|||
"protocol": protocol,
|
||||
"protocol_id": protocol_id
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ from varken.structures import TautulliStream
|
|||
|
||||
class TautulliAPI(object):
|
||||
def __init__(self, server, dbmanager, data_folder):
|
||||
# Set Time of initialization
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
self.dbmanager = dbmanager
|
||||
self.server = server
|
||||
self.session = Session()
|
||||
|
@ -23,7 +21,7 @@ class TautulliAPI(object):
|
|||
return "<tautulli-{}>".format(self.server.id)
|
||||
|
||||
def get_activity(self):
|
||||
self.now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
influx_payload = []
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + self.endpoint))
|
||||
|
@ -119,7 +117,7 @@ class TautulliAPI(object):
|
|||
"device_type": session.platform,
|
||||
"server": self.server.id
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"hash": hash_id
|
||||
}
|
||||
|
@ -133,7 +131,7 @@ class TautulliAPI(object):
|
|||
"type": "current_stream_stats",
|
||||
"server": self.server.id
|
||||
},
|
||||
"time": self.now,
|
||||
"time": now,
|
||||
"fields": {
|
||||
"stream_count": int(get['stream_count']),
|
||||
"total_bandwidth": int(get['total_bandwidth']),
|
||||
|
|
Loading…
Reference in a new issue