mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Move season dedup rule to rule.py
This commit is contained in:
parent
67cbf674b1
commit
cd7bde944e
@ -51,9 +51,6 @@ class Matcher:
|
||||
|
||||
if "mimetype" not in raw or not raw["mimetype"].startswith("video"):
|
||||
return
|
||||
# Remove seasons in "One Piece (1999) 152.mkv" for example
|
||||
if raw.get("season") == raw.get("year") and "season" in raw:
|
||||
del raw["season"]
|
||||
|
||||
logger.info("Identied %s: %s", path, raw)
|
||||
|
||||
|
@ -253,3 +253,42 @@ class XemFixup(Rule):
|
||||
|
||||
if clean(new_title.value) in context["xem_titles"]:
|
||||
return [[title, nmatch[0]], [new_title]]
|
||||
|
||||
|
||||
class SeasonYearDedup(Rule):
|
||||
"""Remove "season" when it's the same as "year"
|
||||
|
||||
Example: "One Piece (1999) 152.mkv"
|
||||
Default:
|
||||
```json
|
||||
{
|
||||
"title": "One Piece",
|
||||
"year": 1999,
|
||||
"season": 1999,
|
||||
"episode": 152,
|
||||
"container": "mkv",
|
||||
"mimetype": "video/x-matroska",
|
||||
"type": "episode"
|
||||
}
|
||||
```
|
||||
Expected:
|
||||
```json
|
||||
{
|
||||
"title": "One Piece",
|
||||
"year": 1999,
|
||||
"episode": 152,
|
||||
"container": "mkv",
|
||||
"mimetype": "video/x-matroska",
|
||||
"type": "episode"
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
priority = POST_PROCESS
|
||||
consequence = [RemoveMatch]
|
||||
|
||||
def when(self, matches: Matches, context) -> Any:
|
||||
season: List[Match] = matches.named("season") # type: ignore
|
||||
year: List[Match] = matches.named("year") # type: ignore
|
||||
if len(season) == 1 and len(year) == 1 and season[0].value == year[0].value:
|
||||
return [season]
|
||||
|
Loading…
x
Reference in New Issue
Block a user