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"} # Example: http://localhost:8000/get_streams?tmdb_id=822119&imdb_id=tt14513804&media_type=movie&title=Dhoom%20Dhaam&year=2025 @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) # if __name__ == "__main__": # import uvicorn # uvicorn.run(app, host="localhost", port=8000)