[160] notifiarr update

pull/1144/head
meisnate12 2 years ago
parent 0570ca8bfe
commit d4427537b4

@ -1 +1 @@
1.17.3-develop159
1.17.3-develop160

@ -35,4 +35,3 @@ collections:
Collectionless:
template:
- name: collectionless
- name: translation

@ -1,10 +1,11 @@
# Notifiarr Attributes
Configuring [Notifiarr](https://notifiarr.com) is optional but can allow you to send the webhooks straight to notifiarr.
Configuring [Notifiarr](https://notifiarr.com) is optional but can allow you to send the [webhooks](webhooks) straight to notifiarr.
A `notifiarr` mapping is in the root of the config file.
Below is a `notifiarr` mapping example and the full set of attributes:
```yaml
notifiarr:
apikey: ####################################
@ -13,9 +14,8 @@ notifiarr:
| Attribute | Allowed Values | Required |
|:----------|:-----------------------------------------|:--------:|
| `apikey` | Notifiarr API Key | ✅ |
| `develop` | Use the Development Version of Notifiarr | ❌ |
Once you have added the apikey your config.yml you have to add `notifiarr` to any webhook to send that notification to Notifiarr.
Once you have added the apikey your config.yml you have to add `notifiarr` to any [webhook](webhooks) to send that notification to Notifiarr.
```yaml
webhooks:
@ -23,5 +23,5 @@ webhooks:
version: notifiarr
run_start: notifiarr
run_end: notifiarr
collection_changes: notifiarr
changes: notifiarr
```

@ -119,8 +119,8 @@ The Run End notification will be sent at the end of every run with statistics.
"items_added": int, // Number of Items added across all Collections/Playlists
"items_removed": int, // Number of Items removed across all Collections/Playlists
"added_to_radarr": int, // Number of Items added to Radarr
"added_to_sonarr": int // Number of Items added to Sonarr
"names": [
"added_to_sonarr": int, // Number of Items added to Sonarr
"names": [ // List of Dictionaries
"name": str, // Name of collection or playlist in the run
"library": str // Library the collection is in or PLAYLIST
]
@ -145,21 +145,21 @@ The Changes Notification will be sent after each collection/playlist containing
"poster_url": str, // Collection/Playlist Poster URL if avaiable
"background": str, // Base64 Encoded Collection/Playlist Background if no poster_url is found
"background_url": str, // Collection/Playlist Background URL if avaiable
"additions": [
"additions": [ // List of Dictionaries
"title": str, // Title of addition
"tmdb_id": int // TMDb ID of addition only appears if it's a Movie
"tmdb_id": int, // TMDb ID of addition only appears if it's a Movie
"tvdb_id": int // TVDb ID of addition only appears if it's a Show
],
"removals": [
"removals": [ // List of Dictionaries
"title": str, // Title of removal
"tmdb_id": int // TMDb ID of removal only appears if it's a Movie
"tmdb_id": int, // TMDb ID of removal only appears if it's a Movie
"tvdb_id": int // TVDb ID of removal only appears if it's a Show
],
"radarr_adds": [
"radarr_adds": [ // List of Dictionaries
"title": str, // Title of the Radarr Add
"id": int // TMDb ID of the Radarr Add
],
"sonarr_adds": [
"sonarr_adds": [ // List of Dictionaries
"title": str, // Title of the Sonarr Add
"id": int // TVDb ID of the Sonarr Add
]

@ -390,11 +390,7 @@ class ConfigFile:
if "notifiarr" in self.data:
logger.info("Connecting to Notifiarr...")
try:
self.NotifiarrFactory = Notifiarr(self, {
"apikey": check_for_attribute(self.data, "apikey", parent="notifiarr", throw=True),
"develop": check_for_attribute(self.data, "develop", parent="notifiarr", var_type="bool", default=False, do_print=False, save=False),
"test": check_for_attribute(self.data, "test", parent="notifiarr", var_type="bool", default=False, do_print=False, save=False)
})
self.NotifiarrFactory = Notifiarr(self, {"apikey": check_for_attribute(self.data, "apikey", parent="notifiarr", throw=True)})
except Failed as e:
if str(e).endswith("is blank"):
logger.warning(e)

@ -5,19 +5,15 @@ from modules.util import Failed
logger = util.logger
base_url = "https://notifiarr.com/api/v1/"
dev_url = "https://dev.notifiarr.com/api/v1/"
class Notifiarr:
def __init__(self, config, params):
self.config = config
self.apikey = params["apikey"]
self.develop = params["develop"]
self.test = params["test"]
self.header = {"X-API-Key": self.apikey}
logger.secret(self.apikey)
logger.debug(f"Environment: {'Test' if self.test else 'Develop' if self.develop else 'Production'}")
url, _ = self.get_url("user/pmm/")
response = self.config.get(url, params={"fetch": "settings"})
response = self.config.get(f"{base_url}user/pmm/", headers=self.header, params={"fetch": "settings"})
try:
response_json = response.json()
except JSONDecodeError as e:
@ -26,11 +22,8 @@ class Notifiarr:
if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"):
logger.debug(f"Response: {response_json}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")
if not self.test and not response_json["details"]["response"]:
if not response_json["details"]["response"]:
raise Failed("Notifiarr Error: Invalid apikey")
def get_url(self, path):
url = f"{dev_url if self.develop else base_url}{'notification/test' if self.test else f'{path}{self.apikey}'}"
logger.trace(url)
params = {"event": "pmm"} if self.test else None
return url, params
def notification(self, json):
return self.config.get(f"{base_url}notification/pmm/", json=json, headers=self.header)

@ -23,6 +23,7 @@ library_types = ["movie", "show", "artist"]
search_translation = {
"episode_title": "episode.title",
"network": "show.network",
"edition": "editionTitle",
"critic_rating": "rating",
"audience_rating": "audienceRating",
"episode_critic_rating": "episode.rating",

@ -23,9 +23,8 @@ class Webhooks:
logger.trace(f"Webhook: {webhook}")
if webhook == "notifiarr":
if self.notifiarr:
url, params = self.notifiarr.get_url("notification/pmm/")
for x in range(6):
response = self.config.get(url, json=json, params=params)
response = self.notifiarr.notification(json)
if response.status_code < 500:
break
else:

Loading…
Cancel
Save