Merge pull request #440 from g0ldyy/development

Add PUBLIC_BASE_URL configuration variable
This commit is contained in:
Goldy
2026-01-04 14:59:25 +01:00
committed by GitHub
4 changed files with 17 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:
+4
View File
@@ -175,6 +175,10 @@ def log_startup_info(settings):
f"Server started on http://{settings.FASTAPI_HOST}:{settings.FASTAPI_PORT} - {settings.FASTAPI_WORKERS} workers",
)
logger.log("COMET", f"Gunicorn Preload App: {settings.GUNICORN_PRELOAD_APP}")
if settings.PUBLIC_BASE_URL:
logger.log("COMET", f"Public Base URL: {settings.PUBLIC_BASE_URL}")
logger.log(
"COMET",
f"Admin Dashboard Password: {settings.ADMIN_DASHBOARD_PASSWORD} - http://{settings.FASTAPI_HOST}:{settings.FASTAPI_PORT}/admin - Public Metrics API: {settings.PUBLIC_METRICS_API}",
+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):