Create identify pipeline

This commit is contained in:
Zoe Roux 2025-05-05 22:26:05 +02:00
parent e774958138
commit 6ecf0b462f
No known key found for this signature in database
4 changed files with 28 additions and 12 deletions

View File

@ -5,7 +5,7 @@ app = FastAPI(
description="API to control the long running scanner or interacting with external databases (themoviedb, tvdb...)\n\n"
+ "Most of those APIs are for admins only.",
openapi_prefix="/scanner",
#lifetime=smth
# lifetime=smth
)

View File

@ -33,7 +33,7 @@ def guessit(
"episode_prefer_number": True,
"excludes": "language",
"expected_title": expected_titles,
"enforce_list": True
"enforce_list": True,
}
| extra_flags,
)
@ -43,6 +43,7 @@ def guessit(
if __name__ == "__main__":
import sys
import json
# from providers.implementations.thexem import TheXemClient
from guessit.jsonutils import GuessitEncoder
from aiohttp import ClientSession

View File

@ -1,7 +1,17 @@
from .models.videos import Video, Guess
from .guess.guess import guessit
from typing import Literal
from itertools import zip_longest
from logging import getLogger
from typing import Awaitable, Callable, Literal
from .guess.guess import guessit
from .models.videos import Guess, Video
logger = getLogger(__name__)
pipeline: list[Callable[[str, Guess], Awaitable[Guess]]] = [
# TODO: add nfo scanner
# TODO: add thexem
# TODO: add anilist
]
async def identify(path: str) -> Video:
@ -38,6 +48,12 @@ async def identify(path: str) -> Video:
raw=raw,
)
for step in pipeline:
try:
guess = await step(path, guess)
except Exception as e:
logger.error("Couldn't run %s.", step.__name__, exc_info=e)
return Video(
path=path,
rendering="",

View File

@ -1,11 +1,10 @@
from typing import Literal
type ExtraKind = (
Literal["other"] |
Literal["trailer"] |
Literal["interview"] |
Literal["behind-the-scene"] |
Literal["deleted-scene"] |
Literal["blooper"]
Literal["other"]
| Literal["trailer"]
| Literal["interview"]
| Literal["behind-the-scene"]
| Literal["deleted-scene"]
| Literal["blooper"]
)