diff --git a/.env.pub b/.env.pub index e15322e..80498a8 100644 --- a/.env.pub +++ b/.env.pub @@ -1,6 +1,6 @@ ADDRESS="0.0.0.0" LISTEN_PORT="7979" -ANIME_NAME="one-piece" +AFL_ANIME_NAME="one-piece" SONARR_URL="https://sonarr.local" SONARR_SERIES_ID="187" SONARR_API_KEY="" diff --git a/README.md b/README.md index 5c073a7..061c18c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ The SoFE (Sonarr Anime Filler Excluder) is a Python application designed to coll - Docker / Docker Compose - Prometheus server setup for collecting metrics. (Optional) +> [!Note] Make sure to obtain the anime name from [Anime Filler List](https://www.animefillerlist.com/). +![alt text](image.png) + ## Installation The SoFE can be easily run as a container. This section covers pulling the Container Image from the GitHub Container Registry and running it. @@ -27,11 +30,16 @@ docker pull ghcr.io/chkpwd/sofe:latest Run the container: ```sh docker run --rm -p 7979:7979 \ - -e SONARR_SERIES_ID=187 \ - -e ANIME_NAME="one-piece" \ - -e SONARR_API_KEY="your_api_key" \ + -e SONARR_URL="https://sonarr.local" \ + -e SONARR_API_KEY="" \ + -e SONARR_SERIES_ID="187" \ + -e AFL_ANIME_NAME="one-piece" \ + -e PLEX_URL="http://127.0.0.1:32400" \ + -e PLEX_TOKEN="" \ + -e CREATE_PLEX_COLLECTION="True" \ + -e MONITOR_NON_FILLER_SONARR_EPISODES="True" \ + -e PLEX_ANIME_LIBRARY="" \ ghcr.io/chkpwd/sofe:latest -``` Alternatively, create docker-compose.yml file with the following content: ```yaml version: '3.8' @@ -41,17 +49,18 @@ services: ports: - "7979:7979" environment: - SONARR_SERIES_ID: 187 - ANIME_NAME: "one-piece" - SONARR_API_KEY: "your_api_key" + SONARR_URL: "https://sonarr.local" + SONARR_API_KEY: "" + SONARR_SERIES_ID: "187" + AFL_ANIME_NAME: "one-piece" + PLEX_URL: "http://127.0.0.1:32400" + PLEX_TOKEN: "" + CREATE_PLEX_COLLECTION: "True" + MONITOR_NON_FILLER_SONARR_EPISODES: "True" + PLEX_ANIME_LIBRARY: "" + ``` Then run with: ```sh docker-compose up -d ``` -Accessing Data (Not done yet) - -With the container running, you can access the exposed metrics by navigating to http://localhost:5000/fillers in your web browser or using a tool like curl: -```sh -curl http://:5000/fillers -``` diff --git a/app/parser.py b/app/parser.py index 7bffd2c..16792e4 100644 --- a/app/parser.py +++ b/app/parser.py @@ -3,10 +3,10 @@ import requests -def get_anime_filler_list(anime_name: str): +def get_anime_filler_list(afl_anime_name: str): """Get the anime filler list.""" - base_url = f"https://www.animefillerlist.com/shows/{anime_name}/" + base_url = f"https://www.animefillerlist.com/shows/{afl_anime_name}/" url = f"{base_url}" data = html.fromstring(requests.get(url).content) filler_ranges = data.xpath( diff --git a/app/plex.py b/app/plex.py index fb52889..84e74a3 100644 --- a/app/plex.py +++ b/app/plex.py @@ -12,13 +12,14 @@ plex = PlexServer(baseurl=var.plex_url, token=var.plex_token) + def create_plex_collection(sonarr_episodes: list[int], fillers: list[int] = []): nonfillers_items: list[Episode] = [] fillers_items: list[Episode] = [] media: ShowSection = plex.library.section(title=var.plex_anime_library) - shows: MediaContainer = media.search(title=var.anime_name) + shows: MediaContainer = media.search(title=var.afl_anime_name) for show in shows: plex_episodes: list[Episode] = show.episodes() diff --git a/constants/variables.py b/constants/variables.py index eef2608..8779c3a 100644 --- a/constants/variables.py +++ b/constants/variables.py @@ -4,7 +4,7 @@ Attributes: listen_address (str): The IP address to listen on. Defaults to 0.0.0.0. listen_port (int): The port to listen on. Defaults to 7979. - anime_name (str): The name of the anime to fetch filler episodes for. + afl_anime_name (str): The name of the anime to fetch filler episodes for. sonarr_url (str): The URL of the Sonarr server. sonarr_series_id (int): The ID of the Sonarr series to update. sonarr_api_key (str): The API key for the Sonarr server. @@ -31,28 +31,24 @@ class UserConfig: """Configuration constants for the application.""" def __init__(self): - self.listen_address: str = self._get_env_var( - "ADDRESS", default="0.0.0.0" - ) - self.listen_port: int = int(self._get_env_var( - "PORT", default="7979" - )) - self.anime_name: str = self._get_env_var("ANIME_NAME", required=True) + self.listen_address: str = self._get_env_var("ADDRESS", default="0.0.0.0") + self.listen_port: int = int(self._get_env_var("PORT", default="7979")) + 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.sonarr_series_id: int = int( + self._get_env_var("SONARR_SERIES_ID", required=True, default="") + ) 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._get_env_var("MONITOR_NON_FILLER_SONARR_EPISODES", default="") + ) 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.create_plex_collection: bool = bool( + self._get_env_var("CREATE_PLEX_COLLECTION", default="") + ) self.plex_anime_library: str = self._get_env_var("PLEX_ANIME_LIBRARY") @staticmethod diff --git a/image.png b/image.png new file mode 100644 index 0000000..6abe5a4 Binary files /dev/null and b/image.png differ diff --git a/main.py b/main.py index e235581..44dd986 100644 --- a/main.py +++ b/main.py @@ -28,15 +28,17 @@ logging.info("Address is set to '%s'", var.listen_address) logging.info("Port is set to '%s'", var.listen_port) - fillers_from_api = get_anime_filler_list(var.anime_name) + fillers_from_api = get_anime_filler_list(var.afl_anime_name) sonarr_episodes_id = get_sonarr_episodes(int(var.sonarr_series_id)) if var.create_plex_collection is True: - create_plex_collection(sonarr_episodes=sonarr_episodes_id, fillers=fillers_from_api) + create_plex_collection( + sonarr_episodes=sonarr_episodes_id, fillers=fillers_from_api + ) for episode in sonarr_episodes_id: - if episode['episode_number'] not in fillers_from_api: - episodes_to_monitor.append(episode.get('id')) + if episode["episode_number"] not in fillers_from_api: + episodes_to_monitor.append(episode.get("id")) logging.debug("Non-Filler Episodes: %s", episodes_to_monitor)