mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add rescan capabilities
This commit is contained in:
parent
21414d6c2f
commit
3521d577c1
@ -2,9 +2,11 @@ import asyncio
|
||||
from typing import Union, Literal
|
||||
from msgspec import Struct, json
|
||||
from logging import getLogger
|
||||
from aio_pika import connect_robust
|
||||
from aio_pika.abc import AbstractIncomingMessage
|
||||
|
||||
from scanner.publisher import Publisher
|
||||
from scanner.scanner import scan
|
||||
|
||||
from matcher.matcher import Matcher
|
||||
|
||||
logger = getLogger(__name__)
|
||||
@ -27,9 +29,11 @@ class Refresh(Message):
|
||||
id: str
|
||||
|
||||
|
||||
class Rescan(Message):
|
||||
pass
|
||||
|
||||
|
||||
decoder = json.Decoder(Union[Scan, Delete, Refresh])
|
||||
decoder = json.Decoder(Union[Scan, Delete, Refresh, Rescan])
|
||||
|
||||
|
||||
class Subscriber(Publisher):
|
||||
@ -45,6 +49,9 @@ class Subscriber(Publisher):
|
||||
ack = await matcher.delete(path)
|
||||
case Refresh(kind, id):
|
||||
ack = await matcher.refresh(kind, id)
|
||||
case Rescan():
|
||||
await scan(None, self, matcher._client)
|
||||
ack = True
|
||||
case _:
|
||||
logger.error(f"Invalid action: {msg.action}")
|
||||
if ack:
|
||||
|
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
from logging import getLogger
|
||||
|
||||
from .publisher import Publisher
|
||||
@ -10,8 +11,10 @@ logger = getLogger(__name__)
|
||||
|
||||
|
||||
async def scan(
|
||||
path: str, publisher: Publisher, client: KyooClient, remove_deleted=False
|
||||
path_: Optional[str], publisher: Publisher, client: KyooClient, remove_deleted=False
|
||||
):
|
||||
path = path_ or os.environ.get("SCANNER_LIBRARY_ROOT", "/video")
|
||||
|
||||
logger.info("Starting the scan. It can take some times...")
|
||||
ignore_pattern = None
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user