mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
wip: Fix scanner's create requests
This commit is contained in:
parent
585f7d2740
commit
0f4f22d6af
@ -1,5 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
from asyncio import CancelledError, TaskGroup, create_task, sleep
|
from asyncio import CancelledError, TaskGroup, create_task
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
@ -58,19 +58,19 @@ class KyooClient(metaclass=Singleton):
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
async def create_movie(self, movie: Movie) -> Resource:
|
async def create_movie(self, movie: Movie) -> Resource:
|
||||||
logger.debug("sending movie %s", movie.model_dump_json())
|
logger.debug("sending movie %s", movie.model_dump_json(by_alias=True))
|
||||||
async with self._client.post(
|
async with self._client.post(
|
||||||
"movies",
|
"movies",
|
||||||
json=movie.model_dump_json(),
|
json=movie.model_dump_json(by_alias=True),
|
||||||
) as r:
|
) as r:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return Resource(**await r.json())
|
return Resource(**await r.json())
|
||||||
|
|
||||||
async def create_serie(self, serie: Serie) -> Resource:
|
async def create_serie(self, serie: Serie) -> Resource:
|
||||||
logger.debug("sending serie %s", serie.model_dump_json())
|
logger.debug("sending serie %s", serie.model_dump_json(by_alias=True))
|
||||||
async with self._client.post(
|
async with self._client.post(
|
||||||
"series",
|
"series",
|
||||||
json=serie.model_dump_json(),
|
json=serie.model_dump_json(by_alias=True),
|
||||||
) as r:
|
) as r:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return Resource(**await r.json())
|
return Resource(**await r.json())
|
||||||
|
@ -104,7 +104,7 @@ class FsScanner:
|
|||||||
async def _register(self, videos: list[str] | set[str]):
|
async def _register(self, videos: list[str] | set[str]):
|
||||||
# TODO: we should probably chunk those
|
# TODO: we should probably chunk those
|
||||||
vids: list[Video] = []
|
vids: list[Video] = []
|
||||||
for path in videos:
|
for path in list(videos)[:1]:
|
||||||
try:
|
try:
|
||||||
vid = await identify(path)
|
vid = await identify(path)
|
||||||
vid = self._match(vid)
|
vid = self._match(vid)
|
||||||
|
@ -685,8 +685,8 @@ class TheMovieDatabase(Provider):
|
|||||||
),
|
),
|
||||||
staff=Person(
|
staff=Person(
|
||||||
slug=to_slug(person["name"]),
|
slug=to_slug(person["name"]),
|
||||||
name=person["name"],
|
name=person["original_name"],
|
||||||
latin_name=person["original_name"],
|
latin_name=person["name"],
|
||||||
image=self._map_image(person["profile_path"]),
|
image=self._map_image(person["profile_path"]),
|
||||||
external_id={
|
external_id={
|
||||||
self.name: MetadataId(
|
self.name: MetadataId(
|
||||||
|
@ -8,10 +8,11 @@ from pydantic import BaseModel, ConfigDict, GetJsonSchemaHandler
|
|||||||
from pydantic.alias_generators import to_camel
|
from pydantic.alias_generators import to_camel
|
||||||
from pydantic.json_schema import JsonSchemaValue
|
from pydantic.json_schema import JsonSchemaValue
|
||||||
from pydantic_core import core_schema
|
from pydantic_core import core_schema
|
||||||
|
from slugify import slugify
|
||||||
|
|
||||||
|
|
||||||
def to_slug(title: str) -> str:
|
def to_slug(title: str) -> str:
|
||||||
return title
|
return slugify(title)
|
||||||
|
|
||||||
|
|
||||||
def clean(val: str) -> str | None:
|
def clean(val: str) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user