forked from dawtmaytrikx/Announced
-
Notifications
You must be signed in to change notification settings - Fork 4
/
sonarr.py
33 lines (24 loc) · 824 Bytes
/
sonarr.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
import datetime
import logging
import utils
import requests
import config
logger = logging.getLogger("SONARR")
logger.setLevel(logging.DEBUG)
cfg = config.init()
def wanted(title, download_link, indexer):
global cfg
approved = False
logger.debug("Notifying Sonarr of release from %s: %s @ %s", indexer, title, download_link)
headers = {'X-Api-Key': cfg['sonarr.apikey']}
params = {
'title': utils.replace_spaces(title, '.'),
'downloadUrl': download_link,
'protocol': 'Torrent',
'publishDate': datetime.datetime.now().isoformat(),
'indexer': indexer
}
resp = requests.post(url="{}/api/release/push".format(cfg['sonarr.url']), headers=headers, params=params).json()
if 'approved' in resp:
approved = resp['approved']
return approved