File size: 1,568 Bytes
e37348d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)