commit
6fc61c22a4
1 changed files with 37 additions and 6 deletions
43
sonarr.py
43
sonarr.py
|
@ -14,11 +14,11 @@ missing = []
|
||||||
influx_payload = []
|
influx_payload = []
|
||||||
|
|
||||||
for show in tv_shows.keys():
|
for show in tv_shows.keys():
|
||||||
name = '{} - S{}E{}'.format(tv_shows[show]['series']['title'], tv_shows[show]['seasonNumber'],
|
seriesTitle = '{}'.format(tv_shows[show]['series']['title'])
|
||||||
tv_shows[show]['episodeNumber'])
|
sxe = 'S{:0>2}E{:0>2}'.format(tv_shows[show]['seasonNumber'],tv_shows[show]['episodeNumber'])
|
||||||
missing.append((name, tv_shows[show]['id']))
|
missing.append((seriesTitle, sxe, tv_shows[show]['id'], tv_shows[show]['title']))
|
||||||
|
|
||||||
for show, id in missing:
|
for seriesTitle, sxe, id, title in missing:
|
||||||
influx_payload.append(
|
influx_payload.append(
|
||||||
{
|
{
|
||||||
"measurement": "Sonarr",
|
"measurement": "Sonarr",
|
||||||
|
@ -28,12 +28,43 @@ for show, id in missing:
|
||||||
},
|
},
|
||||||
"time": current_time,
|
"time": current_time,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": show
|
"name": seriesTitle,
|
||||||
|
"epname": title,
|
||||||
|
"sxe": sxe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
get_upcoming_shows = requests.get('{}/api/calendar/'.format(configuration.sonarr_url),
|
||||||
|
headers=headers).json()
|
||||||
|
upcoming_shows = {d['id']: d for d in get_upcoming_shows}
|
||||||
|
upcoming = []
|
||||||
|
influx_payload2 = []
|
||||||
|
|
||||||
|
for show in upcoming_shows.keys():
|
||||||
|
seriesTitle = '{}'.format(upcoming_shows[show]['series']['title'])
|
||||||
|
sxe = 'S{:0>2}E{:0>2}'.format(upcoming_shows[show]['seasonNumber'],upcoming_shows[show]['episodeNumber'])
|
||||||
|
upcoming.append((seriesTitle, sxe, upcoming_shows[show]['id'], upcoming_shows[show]['title'], upcoming_shows[show]['airDate']))
|
||||||
|
|
||||||
|
for seriesTitle, sxe, id, title, airDate in upcoming:
|
||||||
|
influx_payload2.append(
|
||||||
|
{
|
||||||
|
"measurement": "Sonarr",
|
||||||
|
"tags": {
|
||||||
|
"type": "Soon",
|
||||||
|
"sonarrId": id
|
||||||
|
},
|
||||||
|
"time": current_time,
|
||||||
|
"fields": {
|
||||||
|
"name": seriesTitle,
|
||||||
|
"epname": title,
|
||||||
|
"sxe": sxe,
|
||||||
|
"airs": airDate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
influx = InfluxDBClient(configuration.grafana_url, configuration.grafana_port, configuration.grafana_username,
|
influx = InfluxDBClient(configuration.grafana_url, configuration.grafana_port, configuration.grafana_username,
|
||||||
configuration.grafana_password, configuration.sonarr_grafana_db_name)
|
configuration.grafana_password, configuration.sonarr_grafana_db_name)
|
||||||
influx.write_points(influx_payload)
|
influx.write_points(influx_payload)
|
||||||
|
influx.write_points(influx_payload2)
|
||||||
|
|
Loading…
Reference in a new issue