check payload for sickchill

This commit is contained in:
Nicholas St. Germain 2019-01-25 13:57:27 -06:00
parent c4c1ace54f
commit 371edb9f02

View file

@ -42,23 +42,27 @@ class SickChillAPI(object):
sxe = f'S{show.season:0>2}E{show.episode:0>2}' sxe = f'S{show.season:0>2}E{show.episode:0>2}'
hash_id = hashit(f'{self.server.id}{show.show_name}{sxe}') hash_id = hashit(f'{self.server.id}{show.show_name}{sxe}')
missing_types = [(0, 'future'), (1, 'later'), (2, 'soon'), (3, 'today'), (4, 'missed')] missing_types = [(0, 'future'), (1, 'later'), (2, 'soon'), (3, 'today'), (4, 'missed')]
influx_payload.append( try:
{ influx_payload.append(
"measurement": "SickChill", {
"tags": { "measurement": "SickChill",
"type": [item[0] for item in missing_types if key in item][0], "tags": {
"indexerid": show.indexerid, "type": [item[0] for item in missing_types if key in item][0],
"server": self.server.id, "indexerid": show.indexerid,
"name": show.show_name, "server": self.server.id,
"epname": show.ep_name, "name": show.show_name,
"sxe": sxe, "epname": show.ep_name,
"airdate": show.airdate, "sxe": sxe,
}, "airdate": show.airdate,
"time": now, },
"fields": { "time": now,
"hash": hash_id "fields": {
"hash": hash_id
}
} }
} )
) except IndexError as e:
self.logger.error('Error building payload for sickchill. Discarding. Error: %s', e)
self.dbmanager.write_points(influx_payload) if influx_payload:
self.dbmanager.write_points(influx_payload)