feat & Bugfix: layout en rename (year)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user