логотипы каналов, тест 2

This commit is contained in:
2026-07-02 14:47:37 +03:00
parent e32fdcb74e
commit 03a68ee8ca
9 changed files with 130 additions and 72 deletions

View File

@@ -228,3 +228,45 @@ def build_photo_path(source_key: str | None, filename: str | None) -> str:
def build_empty_photo_path(source_key: str | None = None) -> str:
"""Путь к пустой картинке фото для выбранного источника."""
return build_photo_path(source_key, "EMPTY.png")
def extract_channel_logo_filename(value: str | None) -> str:
"""Возвращает имя файла логотипа телеканала из старого полного пути или нового значения."""
value = str(value or "").strip().strip('"').strip("'")
if not value:
return ""
normalized = value.replace("/", "\\")
filename = normalized.split("\\")[-1].strip()
return filename
def ensure_channel_logo_extension(filename: str) -> str:
filename = extract_channel_logo_filename(filename)
if not filename:
return ""
if "." not in filename.rsplit("\\", 1)[-1]:
return f"{filename}.png"
return filename
def get_channel_logo_base_path(source_key: str | None = None) -> str:
source = get_parser_source(source_key)
return str(source.get("channel_logo_base_path") or "").rstrip("\\/")
def build_channel_logo_path(source_key: str | None, filename: str | None) -> str:
"""Собирает полный путь к логотипу телеканала по источнику турнира."""
logo_file = ensure_channel_logo_extension(filename)
if not logo_file:
return ""
base_path = get_channel_logo_base_path(source_key)
if not base_path:
return logo_file
return f"{base_path}\\{logo_file}"
def build_empty_channel_logo_path(source_key: str | None = None) -> str:
return build_channel_logo_path(source_key, "EMPTY.png")