Spaces:
Running
Running
Hermes Agent commited on
Commit ·
c3ba130
1
Parent(s): 0e94626
fix: preserve browser range streaming
Browse filesKeep Content-Length on proxied media responses so browser players can seek and fast-forward reliably. Add explicit Jellyfin Telegram API credential aliases and honor the configured streamer port during cleanup.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- README.md +6 -0
- apex/gateway/utils.py +1 -1
- apex/tg_streamer.py +13 -3
README.md
CHANGED
|
@@ -182,6 +182,12 @@ Jellyfin: JELLYFIN_MULTI_TOKEN1, JELLYFIN_MULTI_TOKEN2, ...
|
|
| 182 |
Jellyfin's primary bot uses `TELEGRAM_BOT_TOKEN`; FileToLink continues to use
|
| 183 |
`BOT_TOKEN`. Internal ports are isolated automatically:
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
```text
|
| 186 |
FileToLink: 8081
|
| 187 |
Jellyfin Telegram streamer: 8082
|
|
|
|
| 182 |
Jellyfin's primary bot uses `TELEGRAM_BOT_TOKEN`; FileToLink continues to use
|
| 183 |
`BOT_TOKEN`. Internal ports are isolated automatically:
|
| 184 |
|
| 185 |
+
For the Jellyfin Telegram client, use `JELLYFIN_API_ID` and
|
| 186 |
+
`JELLYFIN_API_HASH` with the same valid Telegram application credentials used
|
| 187 |
+
by the Jellyfin bot. These are separate names so a stale or conflicting
|
| 188 |
+
`TELEGRAM_API_ID`/`TELEGRAM_API_HASH` pair cannot prevent Jellyfin from
|
| 189 |
+
starting while FileToLink continues to run.
|
| 190 |
+
|
| 191 |
```text
|
| 192 |
FileToLink: 8081
|
| 193 |
Jellyfin Telegram streamer: 8082
|
apex/gateway/utils.py
CHANGED
|
@@ -89,7 +89,7 @@ def fix_location_header(location: str, default_prefix: str = "") -> str:
|
|
| 89 |
_HOP_BY_HOP_HEADERS = {
|
| 90 |
"connection", "keep-alive", "proxy-authenticate", "proxy-authorization",
|
| 91 |
"te", "trailers", "transfer-encoding", "upgrade",
|
| 92 |
-
"content-
|
| 93 |
}
|
| 94 |
|
| 95 |
def get_client_ip(request: Request) -> str:
|
|
|
|
| 89 |
_HOP_BY_HOP_HEADERS = {
|
| 90 |
"connection", "keep-alive", "proxy-authenticate", "proxy-authorization",
|
| 91 |
"te", "trailers", "transfer-encoding", "upgrade",
|
| 92 |
+
"content-encoding"
|
| 93 |
}
|
| 94 |
|
| 95 |
def get_client_ip(request: Request) -> str:
|
apex/tg_streamer.py
CHANGED
|
@@ -75,8 +75,12 @@ def get_env(*names, default=None):
|
|
| 75 |
return v
|
| 76 |
return default
|
| 77 |
|
| 78 |
-
API_ID = get_env(
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
BOT_TOKEN = get_env("TELEGRAM_BOT_TOKEN", "TG_BOT_TOKEN")
|
| 81 |
RAW_CHANNEL_ID = get_env("TELEGRAM_ALLOWED_CHAT_IDS", "TG_CHANNEL_ID", default="")
|
| 82 |
TMDB_API_KEY = get_env("TMDB_API_KEY")
|
|
@@ -2295,7 +2299,13 @@ async def _prune_orphan_strms(movies_dir, shows_dir, keep):
|
|
| 2295 |
content = fh.read(256)
|
| 2296 |
except OSError:
|
| 2297 |
continue
|
| 2298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2299 |
continue
|
| 2300 |
try:
|
| 2301 |
os.remove(path)
|
|
|
|
| 75 |
return v
|
| 76 |
return default
|
| 77 |
|
| 78 |
+
API_ID = get_env(
|
| 79 |
+
"JELLYFIN_API_ID", "TELEGRAM_API_ID", "TG_API_ID", "API_ID"
|
| 80 |
+
)
|
| 81 |
+
API_HASH = get_env(
|
| 82 |
+
"JELLYFIN_API_HASH", "TELEGRAM_API_HASH", "TG_API_HASH", "API_HASH"
|
| 83 |
+
)
|
| 84 |
BOT_TOKEN = get_env("TELEGRAM_BOT_TOKEN", "TG_BOT_TOKEN")
|
| 85 |
RAW_CHANNEL_ID = get_env("TELEGRAM_ALLOWED_CHAT_IDS", "TG_CHANNEL_ID", default="")
|
| 86 |
TMDB_API_KEY = get_env("TMDB_API_KEY")
|
|
|
|
| 2299 |
content = fh.read(256)
|
| 2300 |
except OSError:
|
| 2301 |
continue
|
| 2302 |
+
stream_port = os.environ.get(
|
| 2303 |
+
"TG_LISTEN_PORT", os.environ.get("PORT", "8080")
|
| 2304 |
+
)
|
| 2305 |
+
if (
|
| 2306 |
+
f"127.0.0.1:{stream_port}" not in content
|
| 2307 |
+
and f"{stream_port}/stream" not in content
|
| 2308 |
+
):
|
| 2309 |
continue
|
| 2310 |
try:
|
| 2311 |
os.remove(path)
|