Notifications: Added Apprise support.

pull/87/head
desimaniac 6 years ago
parent 66a7120520
commit e0438c8a38

@ -31,6 +31,7 @@
- [Movies](#movies)
- [Shows](#shows)
- [Notifications](#notifications)
- [Apprise](#apprise)
- [Pushover](#pushover)
- [Slack](#slack)
- [Radarr](#radarr)
@ -664,15 +665,79 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi
## Notifications
```json
"notifications": {
"apprise": {
"service": "apprise",
"url": "",
"title": ""
},
"verbose": false
},
```
Notification alerts for Traktarr tasks.
_Note: Manual commands need the `--notifications` flag._
For auto (i.e. scheduled) runs, notifications are enabled automatically when notification services are listed in this section.
For manual (i.e. CLI) commands, you need to add the `--notifications` flag.
Supported `services`:
- `apprise`
- `pushover`
- `slack`
_Note: The key name can be anything, but the `service` key must be must be the exact service name (e.g. `pushover`). See below for example._
```json
"notifications": {
"anyname": {
"service": "pushover",
}
},
```
### General
`verbose` - Toggle detailed notifications.
- Default is `true`.
- Set to `false` if you want to reduce the amount of detailed notifications (e.g. just the total vs the names of the movies/shows added).
```json
"notifications": {
"verbose": true
},
```
### Apprise
```json
"notifications": {
"apprise": {
"service": "apprise",
"url": "",
"title": ""
},
"verbose": false
},
```
`url` - Apprise service URL (see [here](https://github.com/caronc/apprise)).
Currently, only Pushover and Slack are supported; others can be added in the future.
- Required.
_Note: The key name (i.e the name right under notifications) can be anything, but the `"service":` must be the exact service name (e.g. `"pushover"`)._
`title` - Notification Title.
- Optional.
- Default is `Traktarr`.
### Pushover
```json
"notifications": {
@ -682,26 +747,21 @@ _Note: The key name (i.e the name right under notifications) can be anything, bu
"user_token": "",
"priority": 0
},
"slack": {
"service": "slack",
"webhook_url": ""
},
"verbose": true
"verbose": false
},
```
`verbose` - Toggle detailed notifications. Default is `true`.
`app_token` - App Token from [Pushover.net](https://pushover.net).
- Set to `false`, if you want to reduce the amount of detailed notifications (e.g. the names of the movies/shows added vs just the total).
- Required.
`user_token` - User Token from [Pushover.net](https://pushover.net).
### Pushover
- Required.
`app_token` - Retrieve from Pushover.net. Required.
`priority` - [Priority](https://pushover.net/api#priority) of the notifications.
`user_token` - Retrieve from Pushover.net. Required.
`priority` - Priority for the messages (see https://pushover.net/api#priority). Optional.
- Optional.
- Choices are: `-2`, `-1`, `0`, `1`, `2`.
@ -713,6 +773,7 @@ _Note: The key name (i.e the name right under notifications) can be anything, bu
### Slack
```json
"notifications": {
"slack": {
"service": "slack",
"webhook_url": "",
@ -720,17 +781,31 @@ _Note: The key name (i.e the name right under notifications) can be anything, bu
"sender_name": "Traktarr",
"sender_icon": ":movie_camera:"
},
"verbose": true
"verbose": false
},
```
`webhook_url` - Webhook URL you get after creating an "Incoming Webhook" under "Custom Integrations" on Slack's Website. Required.
`webhook_url` - [Webhook URL](https://my.slack.com/services/new/incoming-webhook/).
- Required.
`channel` - Slack channel to send the notifications to.
- Optional.
- Default is blank.
`sender_name` - Sender's name for the notifications.
- Optional.
- Default is `Traktarr`.
`channel` - Slack channel. Optional. Default is none.
`sender_icon` - Icon to use for the notifications.
`sender_name` - Name the sender of the message. Optional. Default is `Traktarr`.
- Optional.
`sender_icon` - Icon to use for the message. Optional. Default is `:movie_camera:`
- Default is `:movie_camera:`

@ -1,11 +1,13 @@
from misc.log import logger
from .apprise import Apprise
from .pushover import Pushover
from .slack import Slack
log = logger.get_logger(__name__)
SERVICES = {
'apprise': Apprise,
'pushover': Pushover,
'slack': Slack
}

@ -0,0 +1,32 @@
import apprise
from misc.log import logger
log = logger.get_logger(__name__)
class Apprise:
NAME = "Apprise"
def __init__(self, url, title='Traktarr'):
self.url = url
self.title = title
log.debug("Initialized Apprise notification agent")
def send(self, **kwargs):
if not self.url:
log.error("You must specify a URL when initializing this class")
return False
# send notification
try:
apobj = apprise.Apprise()
apobj.add(self.url)
apobj.notify(
title=self.title,
body=kwargs['message'],
)
except Exception:
log.exception("Error sending notification to %r", self.url)
return False

@ -5,3 +5,4 @@ click==6.7
requests~=2.20.0
pyfiglet
cashier~=1.3
apprise==0.7.7
Loading…
Cancel
Save