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