Add multi episodes/seasons safeguards

This commit is contained in:
Zoe Roux 2024-02-02 17:03:45 +01:00
parent f90d2d2f04
commit 9dde2475fc

View File

@ -7,7 +7,7 @@ import re
from aiohttp import ClientSession from aiohttp import ClientSession
from pathlib import Path from pathlib import Path
from typing import List, Literal, Any from typing import List, Literal, Any
from providers.provider import Provider from providers.provider import Provider, ProviderError
from providers.types.collection import Collection from providers.types.collection import Collection
from providers.types.show import Show from providers.types.show import Show
from providers.types.episode import Episode, PartialShow from providers.types.episode import Episode, PartialShow
@ -88,6 +88,11 @@ class Scanner:
if raw.get("season") == raw.get("year") and "season" in raw: if raw.get("season") == raw.get("year") and "season" in raw:
del raw["season"] del raw["season"]
if isinstance(raw.get("season"), List):
raise ProviderError(f"An episode can't have multiple seasons (found {raw.get("season")} for {path})")
if isinstance(raw.get("episode"), List):
raise ProviderError(f"Multi-episodes files are not yet supported (for {path})")
logging.info("Identied %s: %s", path, raw) logging.info("Identied %s: %s", path, raw)
if raw["type"] == "movie": if raw["type"] == "movie":