mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
wip: Start scan request processor
This commit is contained in:
parent
aeddf3366c
commit
2d397a0ce1
@ -21,7 +21,7 @@ type ImageTask = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// this will only push a task to the image downloader service and not download it instantly.
|
// this will only push a task to the image downloader service and not download it instantly.
|
||||||
// this is both done to prevent to many requests to be sent at once and to make sure POST
|
// this is both done to prevent too many requests to be sent at once and to make sure POST
|
||||||
// requests are not blocked by image downloading or blurhash calculation
|
// requests are not blocked by image downloading or blurhash calculation
|
||||||
export const enqueueOptImage = async (
|
export const enqueueOptImage = async (
|
||||||
tx: Transaction,
|
tx: Transaction,
|
||||||
|
@ -4,3 +4,4 @@ guessit@git+https://github.com/zoriya/guessit
|
|||||||
aiohttp
|
aiohttp
|
||||||
watchfiles
|
watchfiles
|
||||||
langcodes
|
langcodes
|
||||||
|
psycopg[binary]
|
||||||
|
@ -26,7 +26,7 @@ class Scanner:
|
|||||||
except re.error as e:
|
except re.error as e:
|
||||||
logger.error(f"Invalid ignore pattern. Ignoring. Error: {e}")
|
logger.error(f"Invalid ignore pattern. Ignoring. Error: {e}")
|
||||||
|
|
||||||
async def scan(self, path: Optional[str], remove_deleted=False):
|
async def scan(self, path: Optional[str] = None, remove_deleted=False):
|
||||||
if path is None:
|
if path is None:
|
||||||
logger.info("Starting scan at %s. This may take some time...", path)
|
logger.info("Starting scan at %s. This may take some time...", path)
|
||||||
if self._ignore_pattern:
|
if self._ignore_pattern:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from typing import Awaitable, Callable, Literal, Optional, cast
|
from typing import Awaitable, Callable, Literal, cast
|
||||||
|
|
||||||
from .guess.guess import guessit
|
from .guess.guess import guessit
|
||||||
from .models.videos import Guess, Video
|
from .models.videos import Guess, Video
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
|
from .client import KyooClient
|
||||||
from .models.videos import Guess
|
from .models.videos import Guess
|
||||||
from .utils import Model
|
from .utils import Model
|
||||||
|
|
||||||
@ -20,4 +21,28 @@ class Request(Model):
|
|||||||
async def enqueue(requests: list[Request]):
|
async def enqueue(requests: list[Request]):
|
||||||
# insert all requests
|
# insert all requests
|
||||||
# on conflict(kind,title,year) add to the `videos` list
|
# on conflict(kind,title,year) add to the `videos` list
|
||||||
|
|
||||||
|
# notify
|
||||||
|
|
||||||
|
# TODO: how will this conflict be handled if the request is already locked for update (being processed)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class RequestProcessor:
|
||||||
|
def __init__(self, client: KyooClient):
|
||||||
|
self._client = client
|
||||||
|
|
||||||
|
async def process_scan_requests(self):
|
||||||
|
# select for update skip_locked limit 1
|
||||||
|
request: Request = ...
|
||||||
|
|
||||||
|
if request.kind == "movie":
|
||||||
|
movie = await providers.get_movie(request.title, request.year)
|
||||||
|
movie.videos = request.videos
|
||||||
|
await self._client.create_movie(movie)
|
||||||
|
else:
|
||||||
|
serie = await providers.get_serie(request.title, request.year)
|
||||||
|
# for vid in request.videos:
|
||||||
|
# for ep in vid.episodes:
|
||||||
|
# entry = next(x for x in series.entries if (ep.season is None or x.season == ep.season), None)
|
||||||
|
await self._client.create_serie(serie)
|
||||||
|
# delete request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user