Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PlexAniSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions custom_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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
5 changes: 3 additions & 2 deletions custom_mappings_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
start: int(required=False)