-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: support for sonarr / radarr
- Loading branch information
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
from utils.custom_logger import logger | ||
|
||
class RadarrWebhookHandler: | ||
def __init__(self, payload, discord_bot): | ||
self.payload = payload | ||
self.discord_bot = discord_bot | ||
|
||
# Global variables for the class to use in the embed creation | ||
self.event_type = self.payload.get('eventType', 'N/A') | ||
self.instance_name = self.payload.get('instanceName', 'N/A') | ||
self.old_version = self.payload.get('previousVersion', 'N/A') | ||
self.new_version = self.payload.get('newVersion', 'N/A') | ||
self.movie_title = self.payload.get('movie', {}).get('title', 'N/A') | ||
self.movie_year = self.payload.get('movie', {}).get('year', 'N/A') | ||
self.release_data = self.payload.get('release', {}) | ||
self.quality = self.release_data.get('quality', 'N/A') | ||
self.size = self.release_data.get('size', 'N/A') | ||
self.indexer = self.release_data.get('indexer', 'N/A') | ||
self.release_title = self.release_data.get('releaseTitle', 'N/A') | ||
self.custom_format_score = self.release_data.get('customFormatScore', 'N/A') | ||
self.custom_formats = self.release_data.get('customFormats', []) | ||
self.tmdb_id = self.payload.get('movie', {}).get('tmdbId', 'N/A') | ||
self.embed_title = f"{self.movie_title} ({self.movie_year})" | ||
|
||
async def handle_webhook(self): | ||
logger.info(f"Processing Radarr webhook payload for event type: {self.payload.get('eventType')}") | ||
logger.debug(f"Payload: {json.dumps(self.payload, indent=4)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import json | ||
from utils.custom_logger import logger | ||
|
||
class SonarrWebhookHandler: | ||
def __init__(self, payload, discord_bot): | ||
self.payload = payload | ||
self.discord_bot = discord_bot | ||
self.initialize_global_variables() | ||
self.check_request_type() | ||
|
||
def initialize_global_variables(self): | ||
self.event_type = self.payload.get('eventType', 'N/A') | ||
self.instance_name = self.payload.get('instanceName', 'N/A') | ||
self.old_version = self.payload.get('previousVersion', 'N/A') | ||
self.new_version = self.payload.get('newVersion', 'N/A') | ||
self.series = self.payload.get('series', {}) | ||
self.series_title = self.series.get('title', 'N/A') | ||
self.release_data = self.payload.get('release', {}) | ||
self.episodes = self.payload.get('episodes', {}) | ||
self.tvdb_id = self.series.get('tvdbId', 'N/A') | ||
self.quality = self.release_data.get('quality', 'N/A') | ||
self.size = self.release_data.get('size', 'N/A') | ||
self.indexer = self.release_data.get('indexer', 'N/A') | ||
self.release_title = self.release_data.get('releaseTitle', 'N/A') | ||
self.custom_format_score = self.release_data.get('customFormatScore', 'N/A') | ||
self.custom_formats = self.release_data.get('customFormats', []) | ||
self.episode_count = len(self.episodes) | ||
|
||
def check_request_type(self): | ||
if self.episode_count > 1: | ||
self.handle_season_request() | ||
else: | ||
self.handle_episode_request() | ||
|
||
def handle_season_request(self): | ||
self.season_number = self.episodes[0].get('seasonNumber', 'N/A') | ||
self.formatted_season_number = f"{self.season_number:02d}" | ||
self.embed_title = f"{self.series_title} (Season {self.formatted_season_number})" | ||
|
||
def handle_episode_request(self): | ||
self.episode_title = self.episodes[0].get('title', 'N/A') | ||
self.episode_number = self.episodes[0].get('episodeNumber', 'N/A') | ||
self.season_number = self.episodes[0].get('seasonNumber', 'N/A') | ||
self.formatted_episode_number = f"{self.episode_number:02d}" | ||
self.formatted_season_number = f"{self.season_number:02d}" | ||
self.embed_title = f"{self.series_title} (S{self.formatted_season_number}E{self.formatted_episode_number})" | ||
|
||
async def handle_webhook(self): | ||
logger.info(f"Processing Sonarr webhook payload for event type: {self.event_type}") | ||
logger.debug(f"Payload: {json.dumps(self.payload, indent=4)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters