-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add endpoint to manually request items (#551)
* feat: Add endpoint to manually request items * fix: made imdb_id required in request endpoint * fix: let fastapi handle invalid params
- Loading branch information
1 parent
eeb2d00
commit 652671e
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Any, Dict, Optional | ||
|
||
import pydantic | ||
from fastapi import APIRouter, Request | ||
from program.content.overseerr import Overseerr | ||
from program.indexers.trakt import TraktIndexer, get_imdbid_from_tmdb | ||
from program.media.item import MediaItem, Show | ||
from requests import RequestException | ||
from utils.logger import logger | ||
|
||
from .models.overseerr import OverseerrWebhook | ||
|
||
router = APIRouter( | ||
prefix="/actions", | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.post("/request/{imdb_id}") | ||
async def request(request: Request, imdb_id: str) -> Dict[str, Any]: | ||
try: | ||
new_item = MediaItem({"imdb_id": imdb_id, "requested_by": "manually"}) | ||
request.app.program.add_to_queue(new_item) | ||
except Exception as e: | ||
logger.error(f"Failed to create item from imdb_id: {imdb_id}") | ||
return {"success": False, "message": "Failed to create item from imdb_id"} | ||
|
||
return {"success": True, "message": f"Added {imdb_id} to queue"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters