feat & Bugfix: layout en rename (year)

This commit is contained in:
kodi
2026-03-08 07:41:24 +01:00
parent 6bf753e3b7
commit 06c144d2fc
9 changed files with 181 additions and 20 deletions
+12
View File
@@ -1,5 +1,6 @@
import json
import os
import re
import sqlite3
import time
from datetime import datetime, timezone
@@ -410,6 +411,7 @@ class SessionService:
or "Unknown Series"
)
year = episode.get("year") or "0000"
series = self._normalize_series_name(series, year)
title = episode.get("title") or "Untitled"
season_raw = episode.get("season_number") or episode.get("season") or 0
@@ -449,6 +451,16 @@ class SessionService:
"items": previews,
}
def _normalize_series_name(self, series: str, year: int | str) -> str:
text = str(series or "").strip()
year_str = str(year or "").strip()
if not text or not year_str:
return text
# Strip trailing " (YEAR)" to avoid duplicate year in the template output.
pattern = re.compile(rf"\s*\({re.escape(year_str)}\)\s*$")
return pattern.sub("", text).strip()
def execute_rename(self, session_id: str, confirm: bool) -> dict:
if not confirm:
raise ValueError("confirm=true is required to execute rename")