stream-fusion-better/stream_fusion/services/postgresql/models/metadatamapping_model.py
LimeDrive 8468bae024 feat(admin): add metadata mappings table and complete admin UI redesign
Introduce a metadata_mappings table with DAO/model layers for admin-managed
IMDB→TMDB/title overrides, and overhaul the admin panel with a modern
Bootstrap 5 sidebar UI.

- Add metadata_mappings table with migrations (search_titles, year_override)
- Add MetadataMappingDAO with standalone session helpers for use outside FastAPI
- Add new admin pages: dashboard, mappings CRUD, maintenance, config, hash/TMDB search
- Integrate DB mapping lookups into Cinemeta and TMDB metadata providers
- Update catalog views to use DB mappings before hitting external APIs
- Rewrite all admin templates with Bootstrap 5, sidebar navigation, French labels
- Add session-based auth for admin routes with Redis session store
2026-03-29 04:46:51 +02:00

31 lines
1.5 KiB
Python

import time
from typing import Optional
from sqlalchemy import BigInteger, Integer, String, Text
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.orm import Mapped, mapped_column
from stream_fusion.services.postgresql.base import Base
class MetadataMappingModel(Base):
"""Manual IMDb → TMDB / title override mappings, managed from the admin UI."""
__tablename__ = "metadata_mappings"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
imdb_id: Mapped[str] = mapped_column(String(20), nullable=False, unique=True, index=True)
tmdb_id: Mapped[Optional[str]] = mapped_column(String(20), nullable=True, index=True)
title_override: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
media_type: Mapped[str] = mapped_column(String(10), nullable=False, default="series")
notes: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
search_titles: Mapped[Optional[list]] = mapped_column(ARRAY(String()), nullable=True)
year_override: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
created_at: Mapped[int] = mapped_column(BigInteger, nullable=False)
updated_at: Mapped[int] = mapped_column(BigInteger, nullable=False)
def __init__(self, **kwargs):
now = int(time.time())
if "created_at" not in kwargs:
kwargs["created_at"] = now
if "updated_at" not in kwargs:
kwargs["updated_at"] = now
super().__init__(**kwargs)