mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
Add PUBLIC_BASE_URL for playback host override
This commit is contained in:
@@ -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 #
|
||||
# ============================== #
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user