added config minutes setting
This commit is contained in:
parent
b7605ebbcc
commit
a5f138785d
5 changed files with 27 additions and 15 deletions
|
@ -40,9 +40,12 @@ class SonarrServer(NamedTuple):
|
|||
url: str = None
|
||||
api_key: str = None
|
||||
verify_ssl: bool = False
|
||||
missing_days: int = None
|
||||
future_days: int = None
|
||||
missing_days: int = 0
|
||||
missing_days_run_minutes: int = 30
|
||||
future_days: int = 0
|
||||
future_days_run_minutes: int = 30
|
||||
queue: bool = False
|
||||
queue_run_minutes: int = 1
|
||||
|
||||
class Server(NamedTuple):
|
||||
id: int = None
|
||||
|
|
|
@ -61,9 +61,13 @@ class INIParser(object):
|
|||
queue = self.config.getboolean(sonarr_section, 'queue')
|
||||
missing_days = self.config.getint(sonarr_section, 'missing_days')
|
||||
future_days = self.config.getint(sonarr_section, 'future_days')
|
||||
missing_days_run_minutes = self.config.getint(sonarr_section, 'missing_days_run_minutes')
|
||||
future_days_run_minutes = self.config.getint(sonarr_section, 'future_days_run_minutes')
|
||||
queue_run_minutes = self.config.getint(sonarr_section, 'queue_run_minutes')
|
||||
|
||||
self.sonarr_servers.append(SonarrServer(server_id, scheme + url, apikey, verify_ssl,
|
||||
missing_days, future_days, queue))
|
||||
self.sonarr_servers.append(SonarrServer(server_id, scheme + url, apikey, verify_ssl, missing_days,
|
||||
missing_days_run_minutes, future_days,
|
||||
future_days_run_minutes, queue, queue_run_minutes))
|
||||
|
||||
# Parse Radarr options
|
||||
try:
|
||||
|
|
|
@ -31,7 +31,8 @@ class SonarrAPI(object):
|
|||
missing = []
|
||||
headers = {'X-Api-Key': server.api_key}
|
||||
|
||||
get = self.session.get(server.url + endpoint, params=params, headers=headers).json()
|
||||
get = self.session.get(server.url + endpoint, params=params, headers=headers,
|
||||
verify=server.verify_ssl).json()
|
||||
# Iteratively create a list of TVShow Objects from response json
|
||||
tv_shows = [TVShow(**show) for show in get]
|
||||
|
||||
|
@ -74,7 +75,8 @@ class SonarrAPI(object):
|
|||
headers = {'X-Api-Key': server.api_key}
|
||||
params = {'start': self.today, 'end': future}
|
||||
|
||||
get = self.session.get(server.url + endpoint, params=params, headers=headers).json()
|
||||
get = self.session.get(server.url + endpoint, params=params, headers=headers,
|
||||
verify=server.verify_ssl).json()
|
||||
tv_shows = [TVShow(**show) for show in get]
|
||||
|
||||
for show in tv_shows:
|
||||
|
@ -104,7 +106,7 @@ class SonarrAPI(object):
|
|||
self.influx_push(influx_payload)
|
||||
|
||||
@logging
|
||||
def get_queue(self):
|
||||
def get_queue(self, notimplemented):
|
||||
influx_payload = []
|
||||
endpoint = '/api/queue'
|
||||
|
||||
|
@ -112,7 +114,7 @@ class SonarrAPI(object):
|
|||
queue = []
|
||||
headers = {'X-Api-Key': server.api_key}
|
||||
|
||||
get = self.session.get(server.url + endpoint, headers=headers).json()
|
||||
get = self.session.get(server.url + endpoint, headers=headers, verify=server.verify_ssl).json()
|
||||
download_queue = [Queue(**show) for show in get]
|
||||
|
||||
for show in download_queue:
|
||||
|
|
|
@ -24,8 +24,11 @@ apikey = xxxxxxxxxxxxxxxx
|
|||
ssl = false
|
||||
verify_ssl = true
|
||||
missing_days = 7
|
||||
missing_days_run_minutes = 30
|
||||
future_days = 1
|
||||
future_days_run_minutes = 30
|
||||
queue = true
|
||||
queue_run_minutes = 1
|
||||
|
||||
[sonarr-2]
|
||||
url = sonarr2.domain.tld
|
||||
|
|
|
@ -6,9 +6,8 @@ from Varken.iniparser import INIParser
|
|||
from Varken.sonarr import SonarrAPI
|
||||
|
||||
|
||||
def threaded(job):
|
||||
print('test')
|
||||
thread = threading.Thread(target=job)
|
||||
def threaded(job, days=None):
|
||||
thread = threading.Thread(target=job, args=([days]))
|
||||
thread.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -19,12 +18,13 @@ if __name__ == "__main__":
|
|||
|
||||
for server in CONFIG.sonarr_servers:
|
||||
if server.queue:
|
||||
schedule.every(1).minutes.do(threaded, SONARR.get_queue)
|
||||
schedule.every(server.queue_run_minutes).minutes.do(threaded, SONARR.get_queue)
|
||||
if server.missing_days > 0:
|
||||
schedule.every(30).minutes.do(threaded, SONARR.get_missing, server.missing_days)
|
||||
schedule.every(server.missing_days_run_minutes).minutes.do(threaded, SONARR.get_missing,
|
||||
server.missing_days)
|
||||
if server.future_days > 0:
|
||||
schedule.every(30).minutes.do(threaded, SONARR.get_future, server.future_days)
|
||||
|
||||
schedule.every(server.future_days_run_minutes).minutes.do(threaded, SONARR.get_future,
|
||||
server.future_days)
|
||||
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue