From dc90c75d74d55e8d548516afe23139fdc42ab122 Mon Sep 17 00:00:00 2001 From: Bryan Jones Date: Fri, 25 Oct 2024 16:49:10 -0400 Subject: [PATCH] fix: string to bool using attrs func --- app/sonarr.py | 4 ++-- constants/variables.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/sonarr.py b/app/sonarr.py index 22c42ba..d4852c2 100644 --- a/app/sonarr.py +++ b/app/sonarr.py @@ -43,9 +43,9 @@ def configure_monitoring(monitored_list: list): api_instance = sonarr.EpisodeApi(api_client) episodes_monitored_resource = sonarr.EpisodesMonitoredResource( - episodeIds=[*monitored_list] + episodeIds=[*monitored_list], + monitored=True ) - episodes_monitored_resource.monitored = True try: api_instance.put_episode_monitor( diff --git a/constants/variables.py b/constants/variables.py index 3c45f33..fa81a35 100644 --- a/constants/variables.py +++ b/constants/variables.py @@ -1,7 +1,9 @@ import os import sys +import attrs import logging +from attrs.converters import to_bool from dotenv import load_dotenv @@ -34,18 +36,16 @@ def __init__(self): self.afl_anime_name: str = self._get_env_var("AFL_ANIME_NAME", required=True) self.sonarr_url: str = self._get_env_var("SONARR_URL", required=True) self.sonarr_series_id: int = int( - self._get_env_var("SONARR_SERIES_ID", required=True, default="") + self._get_env_var("SONARR_SERIES_ID", required=True) ) self.sonarr_api_key: str = self._get_env_var("SONARR_API_KEY", required=True) - self.monitor_non_filler_sonarr_episodes: bool = bool( - self._get_env_var("MONITOR_NON_FILLER_SONARR_EPISODES", default="") + self.monitor_non_filler_sonarr_episodes: bool = to_bool( + self._get_env_var("MONITOR_NON_FILLER_SONARR_EPISODES", required=True, default="True") ) self.plex_url: str = self._get_env_var("PLEX_URL") - self.plex_token: str = self._get_env_var( - "PLEX_TOKEN", required=bool(self.plex_url) - ) - self.create_plex_collection: bool = bool( - self._get_env_var("CREATE_PLEX_COLLECTION", default="") + self.plex_token: str = self._get_env_var("PLEX_TOKEN") + self.create_plex_collection: bool = to_bool( + self._get_env_var("CREATE_PLEX_COLLECTION", required=True, default="False") ) self.plex_anime_library: str = self._get_env_var("PLEX_ANIME_LIBRARY")