fix: Improve poster handling in catalog formatting and ensure proper output rendering

This commit is contained in:
sHa
2026-01-03 19:44:19 +00:00
parent 65d9759880
commit 5e4ab232ee
4 changed files with 16 additions and 9 deletions

BIN
dist/renamer-0.7.2-py3-none-any.whl vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "renamer" name = "renamer"
version = "0.7.1" version = "0.7.2"
description = "Terminal-based media file renamer and metadata viewer" description = "Terminal-based media file renamer and metadata viewer"
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"

View File

@@ -11,6 +11,7 @@ class CatalogFormatter:
def format_catalog_info(self) -> str: def format_catalog_info(self) -> str:
"""Format catalog information for display""" """Format catalog information for display"""
lines = [] lines = []
poster_output = None
# Title # Title
title = self.extractor.get("title", "TMDB") title = self.extractor.get("title", "TMDB")
@@ -54,24 +55,30 @@ class CatalogFormatter:
if countries: if countries:
lines.append(f"{TextFormatter.bold('Countries:')} {countries}") lines.append(f"{TextFormatter.bold('Countries:')} {countries}")
# Poster # Poster - handle separately to avoid Rich markup processing
poster_image_path = self.extractor.tmdb_extractor.extract_poster_image_path() poster_image_path = self.extractor.tmdb_extractor.extract_poster_image_path()
if poster_image_path: if poster_image_path:
lines.append(f"{TextFormatter.bold('Poster:')}") lines.append(f"{TextFormatter.bold('Poster:')}")
lines.append(self._display_poster(poster_image_path)) poster_output = self._display_poster(poster_image_path)
else: else:
poster_path = self.extractor.get("poster_path", "TMDB") poster_path = self.extractor.get("poster_path", "TMDB")
if poster_path: if poster_path:
lines.append(f"{TextFormatter.bold('Poster:')} {poster_path} (not cached yet)") lines.append(f"{TextFormatter.bold('Poster:')} {poster_path} (not cached yet)")
full_text = "\n\n".join(lines) if lines else "No catalog information available" # Render text content with Rich markup
text_content = "\n\n".join(lines) if lines else "No catalog information available"
# Render markup to ANSI
from rich.console import Console from rich.console import Console
from io import StringIO from io import StringIO
console = Console(file=StringIO(), width=120, legacy_windows=False) console = Console(file=StringIO(), width=120, legacy_windows=False)
console.print(full_text, markup=True) console.print(text_content, markup=True)
return console.file.getvalue() rendered_text = console.file.getvalue()
# Append poster output directly (already contains ANSI codes from viu)
if poster_output:
return rendered_text + "\n" + poster_output
else:
return rendered_text
def _display_poster(self, image_path: str) -> str: def _display_poster(self, image_path: str) -> str:
"""Display poster image in terminal using viu""" """Display poster image in terminal using viu"""

2
uv.lock generated
View File

@@ -462,7 +462,7 @@ wheels = [
[[package]] [[package]]
name = "renamer" name = "renamer"
version = "0.7.1" version = "0.7.2"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "langcodes" }, { name = "langcodes" },