mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 21:54:49 -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 typing import Union, Literal
|
||||||
from msgspec import Struct, json
|
from msgspec import Struct, json
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from aio_pika import connect_robust
|
|
||||||
from aio_pika.abc import AbstractIncomingMessage
|
from aio_pika.abc import AbstractIncomingMessage
|
||||||
|
|
||||||
|
from scanner.publisher import Publisher
|
||||||
|
from scanner.scanner import scan
|
||||||
|
|
||||||
from matcher.matcher import Matcher
|
from matcher.matcher import Matcher
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
@ -27,9 +29,11 @@ class Refresh(Message):
|
|||||||
id: str
|
id: str
|
||||||
|
|
||||||
|
|
||||||
|
class Rescan(Message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
decoder = json.Decoder(Union[Scan, Delete, Refresh])
|
decoder = json.Decoder(Union[Scan, Delete, Refresh, Rescan])
|
||||||
|
|
||||||
|
|
||||||
class Subscriber(Publisher):
|
class Subscriber(Publisher):
|
||||||
@ -45,6 +49,9 @@ class Subscriber(Publisher):
|
|||||||
ack = await matcher.delete(path)
|
ack = await matcher.delete(path)
|
||||||
case Refresh(kind, id):
|
case Refresh(kind, id):
|
||||||
ack = await matcher.refresh(kind, id)
|
ack = await matcher.refresh(kind, id)
|
||||||
|
case Rescan():
|
||||||
|
await scan(None, self, matcher._client)
|
||||||
|
ack = True
|
||||||
case _:
|
case _:
|
||||||
logger.error(f"Invalid action: {msg.action}")
|
logger.error(f"Invalid action: {msg.action}")
|
||||||
if ack:
|
if ack:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Optional
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
from .publisher import Publisher
|
from .publisher import Publisher
|
||||||
@ -10,8 +11,10 @@ logger = getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
async def scan(
|
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...")
|
logger.info("Starting the scan. It can take some times...")
|
||||||
ignore_pattern = None
|
ignore_pattern = None
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user