diff --git a/PlexAniSync.py b/PlexAniSync.py index b3f3c231..fa73ea23 100644 --- a/PlexAniSync.py +++ b/PlexAniSync.py @@ -80,7 +80,7 @@ def read_settings(settings_file) -> configparser.ConfigParser: def start(): logger.info(f"PlexAniSync - version: {__version__}") - anilist.CUSTOM_MAPPINGS = read_custom_mappings() + anilist.CUSTOM_MAPPINGS, anilist.IGNORED_TITLES = read_custom_mappings() if graphql.ANILIST_SKIP_UPDATE: logger.warning( diff --git a/README.md b/README.md index 9a6234c2..7e4c848c 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,13 @@ Episodes 1-13 will be mapped to Re:Zero 2nd Season Part 1, episodes 14 and highe https://anilist.co/anime/99263/Tate-no-Yuusha-no-Nariagari +```yaml + - title: "Plex title for series" + ignore: true +``` + +Prevent a series from syncing. If "seasons" is not set, "ignore: true" is inferred. + - You can remove any existing entries from the example file as they are purely instructional - Upon startup it will check if the file is a valid YAML file. The most likely reason it's not is because you didn't put quotes around an anime title with special characters (e.g. ":") in it. diff --git a/anilist.py b/anilist.py index e8b244bd..5588a056 100644 --- a/anilist.py +++ b/anilist.py @@ -12,6 +12,7 @@ logger = logging.getLogger("PlexAniSync") CUSTOM_MAPPINGS: Dict[str, List[AnilistCustomMapping]] = {} +IGNORED_TITLES: List[str] = [] ANILIST_PLEX_EPISODE_COUNT_PRIORITY = False # Set this to True for logging failed AniList matches to @@ -179,6 +180,10 @@ def match_to_plex(anilist_series: List[AnilistSeries], plex_series_watched: List logger.info("--------------------------------------------------") + if plex_title in IGNORED_TITLES: + logger.info(f'[ANILIST] Ignored: {plex_title}') + continue + # Check if we have custom mappings for all seasons (One Piece for example) if len(plex_seasons) > 1: custom_mapping_season_count = 0 diff --git a/custom_mappings.py b/custom_mappings.py index 78e596c2..327944cb 100644 --- a/custom_mappings.py +++ b/custom_mappings.py @@ -2,7 +2,7 @@ import os import logging import sys -from typing import List +from typing import List, Dict, Union from dataclasses import dataclass import yamale @@ -22,6 +22,7 @@ class AnilistCustomMapping: def read_custom_mappings(): custom_mappings = {} + ignored_titles = [] if not os.path.isfile(MAPPING_FILE): logger.info(f"[MAPPING] Custom map file not found: {MAPPING_FILE}") else: @@ -45,7 +46,17 @@ def read_custom_mappings(): series_title = str(file_entry['title']) synonyms: List[str] = file_entry.get('synonyms', []) series_mappings: List[AnilistCustomMapping] = [] - for file_season in file_entry['seasons']: + seasons: List[Dict[str, Untion[str, int]]] = file_entry.get('seasons', []) + + if not seasons and file_entry.get('ignore') is not True: + logger.warning(f'[MAPPING] "seasons" is not set, thus "ignore" is inferred | title: {series_title}') + + if file_entry.get('ignore', False) or not seasons: + ignored_titles.extend(synonyms + [series_title]) + logger.info(f'[MAPPING] Ignore | title: {series_title}') + continue + + for file_season in seasons: season = file_season['season'] anilist_id = file_season['anilist-id'] start = file_season.get('start', 1) @@ -58,4 +69,4 @@ def read_custom_mappings(): custom_mappings[series_title.lower()] = series_mappings for synonym in synonyms: custom_mappings[synonym.lower()] = series_mappings - return custom_mappings + return custom_mappings, ignored_titles diff --git a/custom_mappings_schema.yaml b/custom_mappings_schema.yaml index fc62f3bb..44681e49 100644 --- a/custom_mappings_schema.yaml +++ b/custom_mappings_schema.yaml @@ -3,9 +3,10 @@ entries: list(include('entry'), min=1) entry: title: str() synonyms: list(str(), required=False) - seasons: list(include('season'), min=1) + seasons: list(include('season'), required=False, min=1) + ignore: bool(required=False) season: season: int(min=1) anilist-id: int(min=1) - start: int(required=False) \ No newline at end of file + start: int(required=False)