forked from Boerderij/Varken
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradarr.py
More file actions
38 lines (31 loc) · 1.14 KB
/
radarr.py
File metadata and controls
38 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Do not edit this script. Edit configuration.py
import requests
from datetime import datetime, timezone
from influxdb import InfluxDBClient
import configuration
current_time = datetime.now(timezone.utc).astimezone().isoformat()
headers = {'X-Api-Key': configuration.radarr_api_key}
get_movies = requests.get('{}/api/movie'.format(configuration.radarr_url), headers=headers).json()
movies = {d['tmdbId']: d for d in get_movies}
missing = []
influx_payload = []
for movie in movies.keys():
if not movies[movie]['downloaded']:
missing.append((movies[movie]['title'], movies[movie]['tmdbId']))
for movie, id in missing:
influx_payload.append(
{
"measurement": "Radarr",
"tags": {
"type": "Missing",
"tmdbId": id
},
"time": current_time,
"fields": {
"name": movie
}
}
)
influx = InfluxDBClient(configuration.grafana_url, configuration.grafana_port, configuration.grafana_username,
configuration.grafana_password, configuration.radarr_grafana_db_name)
influx.write_points(influx_payload)