-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArrQueue.py
56 lines (47 loc) · 2.2 KB
/
ArrQueue.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import requests
import json
#Radarr
radarrAPI = 'https://yourRadarrAddressHere/api/queue?apikey=yourKeyHere' #change https to http if you are not using SSL
radarrUsername = 'yourUsernameHere'
radarrPassword = 'yourPasswordHere'
radarrDiscordWebhook = 'yourWebhookURLHere'
radarrDiscordUserID = 'yourUserIDHere'
queue = json.loads(requests.get(radarrAPI, auth=(radarrUsername, radarrPassword)).content.decode('utf-8'))
for movie in queue:
bad = False
#print(movie['title']+": "+movie['trackedDownloadStatus'])
try:
if movie['trackedDownloadStatus'] == 'Warning':
for status in movie['statusMessages']:
if 'XEM' not in status['messages'][0]:
bad = True
break
if bad:
result = requests.post(r''+radarrDiscordWebhook, data="{\"username\": \"Radarr\", \"content\": \"<@"+radarrDiscordUserID+"> stuck movies found in radarr\"}", headers={"Content-Type": "application/json"})
break
except KeyError:
pass
#Sonarr
sonarrAPI = 'https://yourSonarrAddressHere/api/queue?apikey=yourKeyHere' #change https to http if you are not using SSL
sonarrUsername = 'yourUsernameHere'
sonarrPassword = 'yourPasswordHere'
sonarrDiscordWebhook = 'yourWebhookURLHere'
sonarrDiscordUserID = 'yourUserIDHere'
queue = json.loads(requests.get(sonarrAPI, auth=(sonarrUsername, sonarrPassword)).content.decode('utf-8'))
errors = []
for episode in queue:
bad = False
#print(episode['title']+": "+episode['trackedDownloadStatus'])
try:
if episode['trackedDownloadStatus'] == 'Warning':
for status in episode['statusMessages']:
if 'XEM' not in status['messages'][0] and 'TBA' not in status['messages'][0]:
bad = True
break
if bad:
if episode['title'] not in errors:
result = requests.post(r''+sonarrDiscordWebhook, data="{\"username\": \"Sonarr\", \"content\": \"<@"+sonarrDiscordUserID+"> stuck TV found in sonarr\"}", headers={"Content-Type": "application/json"})
errors.append(episode['title'])
break
except KeyError:
pass