|
|
import json
|
|
|
import fastapi
|
|
|
from fastapi.params import Query
|
|
|
from fastapi.responses import JSONResponse
|
|
|
from get_streams import get_streams as fetch_streams
|
|
|
import traceback
|
|
|
|
|
|
app = fastapi.FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
|
async def root():
|
|
|
return {"status": "Online"}
|
|
|
|
|
|
|
|
|
@app.get("/get_streams")
|
|
|
async def get_streams_api(
|
|
|
tmdb_id: str = Query(..., description="TMDB ID"),
|
|
|
imdb_id: str = Query(..., description="IMDB ID"),
|
|
|
media_type: str = Query(..., description="Media Type (e.g., movie, series)"),
|
|
|
title: str = Query(..., description="Title of the media"),
|
|
|
year: str = Query(..., description="Release Year"),
|
|
|
season: str = Query(None, description="Season number for series (optional)"),
|
|
|
episode: str = Query(None, description="Episode number for series (optional)")
|
|
|
):
|
|
|
"""
|
|
|
Get streams from various providers based on the provided parameters.
|
|
|
"""
|
|
|
try:
|
|
|
stream_list = fetch_streams(
|
|
|
tmdb_id=tmdb_id,
|
|
|
imdb_id=imdb_id,
|
|
|
media_type=media_type,
|
|
|
title=title,
|
|
|
year=year,
|
|
|
season=season,
|
|
|
episode=episode,
|
|
|
)
|
|
|
return JSONResponse(content=json.loads(stream_list))
|
|
|
except Exception as e:
|
|
|
return JSONResponse(content={"error": str(e)}, status_code=500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|