Files
pie 067cc51cf2
Build and Push Docker Image / build-and-push (push) Failing after 10m6s
feat: resolve chromecast discovery conflict and add CI/CD workflow
- Update Zeroconf to unicast mode to resolve port 5353 conflict with avahi-daemon
- Make API and Streamlit ports configurable via environment variables (defaults: 8055, 8505)
- Add Gitea Actions workflow for automated Docker builds and registry pushes
- Refactor Chromecast discovery to use modern CastBrowser API
2026-05-03 17:19:26 +01:00

50 lines
1.4 KiB
Python

import logging
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Path configuration
BASE_DIR = Path(__file__).resolve().parent.parent
CONFIG_DIR = Path(os.getenv("CONFIG_DIR", BASE_DIR / "config"))
VIDEOS_DIR = Path(os.getenv("VIDEOS_DIR", BASE_DIR / "videos"))
THUMBNAILS_DIR = CONFIG_DIR / "thumbnails"
# Ensure directories exist
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
THUMBNAILS_DIR.mkdir(parents=True, exist_ok=True)
VIDEOS_DIR.mkdir(parents=True, exist_ok=True)
# Port configuration
API_PORT = int(os.getenv("API_PORT", "8055"))
STREAMLIT_PORT = int(os.getenv("STREAMLIT_PORT", "8505"))
# Logging configuration
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
handlers=[
logging.StreamHandler(),
logging.FileHandler(CONFIG_DIR / "app.log")
]
)
def get_logger(name: str):
return logging.getLogger(name)
def get_host_ip():
"""Returns the host IP to be used for Chromecast.
In host networking mode, we can use a socket to find the primary interface IP."""
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.255.255.255', 1))
IP = s.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
s.close()
return IP