refactor find_links.py by adding methods for specific tasks
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from typing import List, AnyStr
|
||||
|
||||
from fastapi import APIRouter, status, HTTPException
|
||||
from sqlalchemy import select
|
||||
from src.core.log_conf import logger
|
||||
@@ -10,10 +8,10 @@ from src.db.models.media import MediaActor
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/actors", response_model=List[MediaActorResponse])
|
||||
#def get_all_files(db: SessionDep, review: bool = False, download: bool = False, current_user: Profile = Depends(get_current_user_from_token)) -> List[MediaFileResponse]:
|
||||
def get_all_actors(db: SessionDep, review: bool = False, download: bool = False) -> List[MediaActorResponse]:
|
||||
results: List[MediaActorResponse] = []
|
||||
@router.get("/actors", response_model=list[MediaActorResponse])
|
||||
# def get_all_files(db: SessionDep, review: bool = False, download: bool = False, current_user: Profile = Depends(get_current_user_from_token)) -> List[MediaFileResponse]:
|
||||
def get_all_actors(db: SessionDep, review: bool = False, download: bool = False) -> list[MediaActorResponse]:
|
||||
results: list[MediaActorResponse] = []
|
||||
actors = db.scalars(select(MediaActor)).all()
|
||||
for mediaactor in actors:
|
||||
response = MediaActorResponse(id=mediaactor.id, name=str(mediaactor.name), url=str(mediaactor.url))
|
||||
@@ -21,7 +19,7 @@ def get_all_actors(db: SessionDep, review: bool = False, download: bool = False)
|
||||
return results
|
||||
|
||||
@router.get("/actors/{actor_id}", response_model=MediaActorResponse)
|
||||
def get_actor(actor_id: AnyStr, db: SessionDep) -> MediaActorResponse:
|
||||
def get_actor(actor_id: str, db: SessionDep) -> MediaActorResponse:
|
||||
media_actor = db.get(MediaActor, actor_id)
|
||||
if not media_actor:
|
||||
raise HTTPException(status_code=404, detail="MediaActor could not be found")
|
||||
|
||||
Reference in New Issue
Block a user