Skip to content

Commit

Permalink
feat: error videos added to playback
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Jul 18, 2024
1 parent 19fc235 commit 83668ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import httpx

from fastapi import APIRouter, Request
from fastapi.responses import RedirectResponse, StreamingResponse
from fastapi.responses import RedirectResponse, StreamingResponse, FileResponse
from starlette.background import BackgroundTask
from RTN import Torrent, sort_torrents

Expand Down Expand Up @@ -349,24 +349,20 @@ async def stream(request: Request, b64config: str, type: str, id: str):

@streams.head("/{b64config}/playback/{hash}/{index}")
async def playback(b64config: str, hash: str, index: str):
config = config_check(b64config)
if not config:
return

return RedirectResponse("https://stremio.fast", status_code=302)


@streams.get("/{b64config}/playback/{hash}/{index}")
async def playback(request: Request, b64config: str, hash: str, index: str):
config = config_check(b64config)
if not config:
return
return FileResponse("comet/assets/invalidconfig.mp4")

async with aiohttp.ClientSession() as session:
debrid = getDebrid(session, config)
download_link = await debrid.generate_download_link(hash, index)
if download_link is None:
return
return FileResponse("comet/assets/uncached.mp4")

proxy = (
debrid.proxy if config["debridService"] == "alldebrid" else None
Expand Down Expand Up @@ -419,6 +415,6 @@ async def close(self):
},
background=BackgroundTask(await streamer.close()),
)
return
return FileResponse("comet/assets/uncached.mp4")

return RedirectResponse(download_link, status_code=302)
Binary file added comet/assets/invalidconfig.mp4
Binary file not shown.
Binary file added comet/assets/uncached.mp4
Binary file not shown.

0 comments on commit 83668ea

Please sign in to comment.