File size: 2,157 Bytes
1404692 36dde81 1404692 d33f42e 36dde81 07f63a8 36dde81 1404692 36dde81 07f63a8 7787e06 36dde81 d33f42e 36dde81 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from os import getenv, path
from dotenv import load_dotenv
load_dotenv(path.join(path.dirname(path.dirname(__file__)), "config.env"))
def _int_env(key: str, default: int = 0) -> int:
try:
return int((getenv(key) or "").strip())
except ValueError:
return default
#----- Environment-backed configuration
class Telegram:
#----- Required: Telegram clients
API_ID = _int_env("API_ID")
API_HASH = getenv("API_HASH", "")
BOT_TOKEN = getenv("BOT_TOKEN", "")
#----- Required: Database URIs
DATABASE = [db.strip() for db in (getenv("DATABASE") or "").split(",") if db.strip()]
#----- Required: Server
PORT = _int_env("PORT", 8000)
OWNER_ID = _int_env("OWNER_ID")
#----- Read/Write via SettingsManager
REPLACE_MODE = getenv("REPLACE_MODE", "true").lower() == "true"
HIDE_CATALOG = getenv("HIDE_CATALOG", "false").lower() == "true"
AUTH_CHANNEL = [c.strip() for c in (getenv("AUTH_CHANNEL") or "").split(",") if c.strip()]
TMDB_API = getenv("TMDB_API", "")
TVDB_API = getenv("TVDB_API", "")
BASE_URL = getenv("BASE_URL", "").rstrip("/")
UPSTREAM_REPO = getenv("UPSTREAM_REPO", "")
UPSTREAM_BRANCH = getenv("UPSTREAM_BRANCH", "")
ADMIN_USERNAME = getenv("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD = getenv("ADMIN_PASSWORD", "admin")
SUBSCRIPTION = getenv("SUBSCRIPTION", "false").lower() == "true"
SUBSCRIPTION_GROUP_ID = _int_env("SUBSCRIPTION_GROUP_ID")
APPROVER_IDS = [int(x.strip()) for x in (getenv("APPROVER_IDS") or "").split(",") if x.strip().isdigit()]
HTTP_PROXY_URL = getenv("HTTP_Proxy_URL", "")
SHOW_PROXY_AND_NON_PROXY_BOTH = getenv("SHOW_ProxyAndNonProxyBoth", "false").lower() == "true"
#----- WebDAV (optional env fallback; prefer Settings page)
WEBDAV_USER = getenv("WEBDAV_USER", "")
WEBDAV_PASSWORD = getenv("WEBDAV_PASSWORD", "")
|