mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-12-03 11:45:09 -05:00
29 lines
596 B
Python
29 lines
596 B
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, BackgroundTasks, Security
|
|
|
|
from ..fsscan import create_scanner
|
|
from ..jwt import validate_bearer
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.put(
|
|
"/scan",
|
|
status_code=204,
|
|
response_description="Scan started.",
|
|
)
|
|
async def trigger_scan(
|
|
tasks: BackgroundTasks,
|
|
_: Annotated[None, Security(validate_bearer, scopes=["scanner.trigger"])],
|
|
):
|
|
"""
|
|
Trigger a full scan of the filesystem, trying to find new videos & deleting old ones.
|
|
"""
|
|
|
|
async def run():
|
|
async with create_scanner() as scanner:
|
|
await scanner.scan()
|
|
|
|
tasks.add_task(run)
|