mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Create identify pipeline
This commit is contained in:
parent
e774958138
commit
6ecf0b462f
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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="",
|
||||
|
@ -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"]
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user