weebzone commited on
Commit ·
ee62341
1
Parent(s): 4232240
`V-1.2.1 Patch`
Browse files>Fix issue while uploading file
> Slightly boost up Streaming Speed
- Backend/__init__.py +1 -1
- Backend/fastapi/routes/stream_routes.py +22 -11
- Backend/helper/modal.py +6 -6
- pyproject.toml +1 -1
- uv.lock +1 -1
Backend/__init__.py
CHANGED
|
@@ -11,4 +11,4 @@ StartTime = time()
|
|
| 11 |
USE_DEFAULT_ID: str = None
|
| 12 |
db = Database()
|
| 13 |
|
| 14 |
-
__version__ = "1.2.
|
|
|
|
| 11 |
USE_DEFAULT_ID: str = None
|
| 12 |
db = Database()
|
| 13 |
|
| 14 |
+
__version__ = "1.2.1"
|
Backend/fastapi/routes/stream_routes.py
CHANGED
|
@@ -28,7 +28,7 @@ def parse_range_header(range_header: str, file_size: int) -> Tuple[int, int]:
|
|
| 28 |
if (until_bytes > file_size - 1) or (from_bytes < 0) or (until_bytes < from_bytes):
|
| 29 |
raise HTTPException(
|
| 30 |
status_code=416,
|
| 31 |
-
detail="Range
|
| 32 |
headers={"Content-Range": f"bytes */{file_size}"},
|
| 33 |
)
|
| 34 |
|
|
@@ -36,6 +36,7 @@ def parse_range_header(range_header: str, file_size: int) -> Tuple[int, int]:
|
|
| 36 |
|
| 37 |
|
| 38 |
@router.get("/dl/{id}/{name}")
|
|
|
|
| 39 |
async def stream_handler(request: Request, id: str, name: str):
|
| 40 |
decoded_data = await decode_string(id)
|
| 41 |
if not decoded_data.get("msg_id"):
|
|
@@ -92,15 +93,25 @@ async def media_streamer(
|
|
| 92 |
if not file_id.file_name and "/" in mime_type:
|
| 93 |
file_name = f"{secrets.token_hex(2)}.{mime_type.split('/')[1]}"
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
return StreamingResponse(
|
| 96 |
-
status_code=
|
| 97 |
content=body,
|
| 98 |
-
headers=
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
"Content-Length": str(req_length),
|
| 102 |
-
"Content-Disposition": f'inline; filename="{file_name}"',
|
| 103 |
-
"Accept-Ranges": "bytes",
|
| 104 |
-
},
|
| 105 |
-
)
|
| 106 |
-
|
|
|
|
| 28 |
if (until_bytes > file_size - 1) or (from_bytes < 0) or (until_bytes < from_bytes):
|
| 29 |
raise HTTPException(
|
| 30 |
status_code=416,
|
| 31 |
+
detail="Requested Range Not Satisfiable",
|
| 32 |
headers={"Content-Range": f"bytes */{file_size}"},
|
| 33 |
)
|
| 34 |
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
@router.get("/dl/{id}/{name}")
|
| 39 |
+
@router.head("/dl/{id}/{name}")
|
| 40 |
async def stream_handler(request: Request, id: str, name: str):
|
| 41 |
decoded_data = await decode_string(id)
|
| 42 |
if not decoded_data.get("msg_id"):
|
|
|
|
| 93 |
if not file_id.file_name and "/" in mime_type:
|
| 94 |
file_name = f"{secrets.token_hex(2)}.{mime_type.split('/')[1]}"
|
| 95 |
|
| 96 |
+
headers = {
|
| 97 |
+
"Content-Type": mime_type,
|
| 98 |
+
"Content-Length": str(req_length),
|
| 99 |
+
"Content-Disposition": f'inline; filename="{file_name}"',
|
| 100 |
+
"Accept-Ranges": "bytes",
|
| 101 |
+
"Cache-Control": "public, max-age=3600, immutable",
|
| 102 |
+
"Access-Control-Allow-Origin": "*",
|
| 103 |
+
"Access-Control-Expose-Headers": "Content-Length, Content-Range, Accept-Ranges",
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
if range_header:
|
| 107 |
+
headers["Content-Range"] = f"bytes {from_bytes}-{until_bytes}/{file_size}"
|
| 108 |
+
status_code = 206
|
| 109 |
+
else:
|
| 110 |
+
status_code = 200
|
| 111 |
+
|
| 112 |
return StreamingResponse(
|
| 113 |
+
status_code=status_code,
|
| 114 |
content=body,
|
| 115 |
+
headers=headers,
|
| 116 |
+
media_type=mime_type,
|
| 117 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend/helper/modal.py
CHANGED
|
@@ -23,10 +23,10 @@ class TVShowSchema(BaseModel):
|
|
| 23 |
imdb_id: Optional[str] = None
|
| 24 |
db_index: int
|
| 25 |
title: str
|
| 26 |
-
genres: List[str]
|
| 27 |
description: Optional[str] = None
|
| 28 |
-
rating: float
|
| 29 |
-
release_year: int
|
| 30 |
poster: Optional[str] = None
|
| 31 |
backdrop: Optional[str] = None
|
| 32 |
logo: Optional[str] = None
|
|
@@ -39,10 +39,10 @@ class MovieSchema(BaseModel):
|
|
| 39 |
imdb_id: Optional[str] = None
|
| 40 |
db_index: int
|
| 41 |
title: str
|
| 42 |
-
genres: List[str]
|
| 43 |
description: Optional[str] = None
|
| 44 |
-
rating: float
|
| 45 |
-
release_year: int
|
| 46 |
poster: Optional[str] = None
|
| 47 |
backdrop: Optional[str] = None
|
| 48 |
logo: Optional[str] = None
|
|
|
|
| 23 |
imdb_id: Optional[str] = None
|
| 24 |
db_index: int
|
| 25 |
title: str
|
| 26 |
+
genres: Optional[List[str]] = None
|
| 27 |
description: Optional[str] = None
|
| 28 |
+
rating: Optional[float] = None
|
| 29 |
+
release_year: Optional[int] = None
|
| 30 |
poster: Optional[str] = None
|
| 31 |
backdrop: Optional[str] = None
|
| 32 |
logo: Optional[str] = None
|
|
|
|
| 39 |
imdb_id: Optional[str] = None
|
| 40 |
db_index: int
|
| 41 |
title: str
|
| 42 |
+
genres: Optional[List[str]] = None
|
| 43 |
description: Optional[str] = None
|
| 44 |
+
rating: Optional[float] = None
|
| 45 |
+
release_year: Optional[int] = None
|
| 46 |
poster: Optional[str] = None
|
| 47 |
backdrop: Optional[str] = None
|
| 48 |
logo: Optional[str] = None
|
pyproject.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
[project]
|
| 2 |
name = "Telegram-Stremio"
|
| 3 |
-
version = "1.2.
|
| 4 |
description = "A powerful, self-hosted Telegram Stremio Media Server built with FastAPI, MongoDB, and PyroFork seamlessly integrated with Stremio for automated media streaming and discovery."
|
| 5 |
readme = "README.md"
|
| 6 |
requires-python = ">=3.11"
|
|
|
|
| 1 |
[project]
|
| 2 |
name = "Telegram-Stremio"
|
| 3 |
+
version = "1.2.1"
|
| 4 |
description = "A powerful, self-hosted Telegram Stremio Media Server built with FastAPI, MongoDB, and PyroFork seamlessly integrated with Stremio for automated media streaming and discovery."
|
| 5 |
readme = "README.md"
|
| 6 |
requires-python = ">=3.11"
|
uv.lock
CHANGED
|
@@ -901,7 +901,7 @@ wheels = [
|
|
| 901 |
|
| 902 |
[[package]]
|
| 903 |
name = "telegram-stremio"
|
| 904 |
-
version = "1.
|
| 905 |
source = { virtual = "." }
|
| 906 |
dependencies = [
|
| 907 |
{ name = "aiofiles" },
|
|
|
|
| 901 |
|
| 902 |
[[package]]
|
| 903 |
name = "telegram-stremio"
|
| 904 |
+
version = "1.2.0"
|
| 905 |
source = { virtual = "." }
|
| 906 |
dependencies = [
|
| 907 |
{ name = "aiofiles" },
|