Some checks failed
CI / skip-ci-check (pull_request) Successful in 1m4s
CI / lint-and-type-check (pull_request) Has been cancelled
CI / python-lint (pull_request) Has been cancelled
CI / test-backend (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / secret-scanning (pull_request) Has been cancelled
CI / dependency-scan (pull_request) Has been cancelled
CI / sast-scan (pull_request) Has been cancelled
CI / workflow-summary (pull_request) Has been cancelled
Add on-demand H.264/AAC web playback (RQ, ffmpeg) with API routes and Next.js proxies; extend admin UI with WebPlaybackVideo and shared hooks. Store transcode cache beside pending-photos (WEB_VIDEO_CACHE_DIR / UPLOAD_DIR) and ignore data/web_videos. Centralize FastAPI URL helpers, optional Vite and Next base paths for subfolder deploy, and fix modal reopen by using router.replace when closing the home photo viewer. Include migration, install scripts, deployment doc updates, and CI admin build env tweak. Made-with: Cursor
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
"""Application settings for PunimTag Web."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
APP_TITLE = "PunimTag Web API"
|
|
APP_VERSION = "0.1.0"
|
|
|
|
# Photo storage settings
|
|
PHOTO_STORAGE_DIR = os.getenv("PHOTO_STORAGE_DIR", "data/uploads")
|
|
|
|
|
|
def _project_root() -> Path:
|
|
"""Repository root (parent of ``backend/``)."""
|
|
return Path(__file__).resolve().parent.parent
|
|
|
|
|
|
def get_web_video_cache_directory() -> Path:
|
|
"""Filesystem directory for browser-safe transcoded MP4 cache.
|
|
|
|
Resolution order:
|
|
|
|
1. ``WEB_VIDEO_CACHE_DIR`` if set (absolute or relative to project root).
|
|
2. Otherwise ``<parent of UPLOAD_DIR>/web_videos`` when ``UPLOAD_DIR`` or
|
|
``PENDING_PHOTOS_DIR`` is set (same layout as ``.../pending-photos`` next to
|
|
``.../web_videos``).
|
|
3. Otherwise ``<project>/data/web_videos`` for local dev when no upload dir
|
|
is configured on the API process.
|
|
"""
|
|
explicit = (os.getenv("WEB_VIDEO_CACHE_DIR") or "").strip()
|
|
if explicit:
|
|
path = Path(explicit).expanduser()
|
|
if not path.is_absolute():
|
|
path = (_project_root() / path).resolve()
|
|
else:
|
|
path = path.resolve()
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
pending_raw = (os.getenv("UPLOAD_DIR") or os.getenv("PENDING_PHOTOS_DIR") or "").strip()
|
|
if pending_raw:
|
|
pending = Path(pending_raw).expanduser()
|
|
if not pending.is_absolute():
|
|
pending = (_project_root() / pending).resolve()
|
|
else:
|
|
pending = pending.resolve()
|
|
out = (pending.parent / "web_videos").resolve()
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
return out
|
|
|
|
fallback = (_project_root() / "data" / "web_videos").resolve()
|
|
fallback.mkdir(parents=True, exist_ok=True)
|
|
return fallback
|
|
|
|
|