Add PUBLIC_BASE_URL for playback host override

This commit is contained in:
SolitudePy
2026-01-04 01:38:31 +02:00
parent 620dca33c8
commit 806483775f
3 changed files with 13 additions and 1 deletions
+5
View File
@@ -28,6 +28,11 @@ FASTAPI_WORKERS=1 # DO NOT change this if you don't know what you are doing. Set
USE_GUNICORN=True # Will use uvicorn if False or if on Windows
GUNICORN_PRELOAD_APP=True # Set to False to start workers without preloading the app (reduces startup cost but requires schema to exist)
# ============================== #
# Playback Settings #
# ============================== #
PUBLIC_BASE_URL= # Optional: force playback URLs to use this public base (e.g. https://comet.example.com). Leave empty to use the request host.
# ============================== #
# Dashboard Settings #
# ============================== #
+6 -1
View File
@@ -509,6 +509,11 @@ async def stream(
result_episode = episode if episode is not None else "n"
torrents = torrent_manager.torrents
base_playback_host = (
settings.PUBLIC_BASE_URL
if settings.PUBLIC_BASE_URL
else f"{request.url.scheme}://{request.url.netloc}"
)
for info_hash in torrent_manager.ranked_torrents:
torrent = torrents[info_hash]
rtn_data = torrent["parsed"]
@@ -556,7 +561,7 @@ async def stream(
the_stream["sources"] = torrent["sources"]
else:
the_stream["url"] = (
f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{info_hash}/{torrent['fileIndex'] if torrent['cached'] and torrent['fileIndex'] is not None else 'n'}/{result_season}/{result_episode}/{quote(torrent_title)}?name={quote(title)}"
f"{base_playback_host}/{b64config}/playback/{info_hash}/{torrent['fileIndex'] if torrent['cached'] and torrent['fileIndex'] is not None else 'n'}/{result_season}/{result_episode}/{quote(torrent_title)}?name={quote(title)}"
)
if sort_mixed:
+2
View File
@@ -116,6 +116,7 @@ class AppSettings(BaseSettings):
"Direct torrent playback is disabled on this server."
)
TORRENT_DISABLED_STREAM_URL: Optional[str] = "https://comet.fast"
PUBLIC_BASE_URL: Optional[str] = None
REMOVE_ADULT_CONTENT: Optional[bool] = False
BACKGROUND_SCRAPER_ENABLED: Optional[bool] = False
BACKGROUND_SCRAPER_CONCURRENT_WORKERS: Optional[int] = 1
@@ -176,6 +177,7 @@ class AppSettings(BaseSettings):
"JACKETTIO_URL",
"JACKETT_URL",
"PROWLARR_URL",
"PUBLIC_BASE_URL",
)
def normalize_urls(cls, v):
if isinstance(v, str):