diff --git a/dist/renamer-0.7.1-py3-none-any.whl b/dist/renamer-0.7.1-py3-none-any.whl new file mode 100644 index 0000000..7ca75b9 Binary files /dev/null and b/dist/renamer-0.7.1-py3-none-any.whl differ diff --git a/pyproject.toml b/pyproject.toml index 36d2090..76ec802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "renamer" -version = "0.6.12" +version = "0.7.1" description = "Terminal-based media file renamer and metadata viewer" readme = "README.md" requires-python = ">=3.11" diff --git a/renamer/formatters/catalog_formatter.py b/renamer/formatters/catalog_formatter.py index c9eb2f4..9e168cb 100644 --- a/renamer/formatters/catalog_formatter.py +++ b/renamer/formatters/catalog_formatter.py @@ -74,39 +74,31 @@ class CatalogFormatter: return console.file.getvalue() def _display_poster(self, image_path: str) -> str: - """Display poster image in terminal using simple ASCII art""" + """Display poster image in terminal using viu""" + import subprocess + import shutil + + if not os.path.exists(image_path): + return f"Image file not found: {image_path}" + + # Check if viu is available + if not shutil.which('viu'): + return f"viu not installed. Install with: cargo install viu\nPoster at: {image_path}" + try: - from PIL import Image - import os - - if not os.path.exists(image_path): - return f"Image file not found: {image_path}" - - # Open and resize image - img = Image.open(image_path).convert('L').resize((80, 40), Image.Resampling.LANCZOS) - - # ASCII characters from dark to light - ascii_chars = '@%#*+=-:. ' - - # Convert to ASCII - pixels = img.getdata() - width, height = img.size - - ascii_art = [] - for y in range(0, height, 2): # Skip every other row for aspect ratio - row = [] - for x in range(width): - # Average of two rows for better aspect - pixel1 = pixels[y * width + x] if y < height else 255 - pixel2 = pixels[(y + 1) * width + x] if y + 1 < height else 255 - avg = (pixel1 + pixel2) // 2 - char = ascii_chars[avg * len(ascii_chars) // 256] - row.append(char) - ascii_art.append(''.join(row)) - - return '\n'.join(ascii_art) - - except ImportError: - return f"Image at {image_path} (PIL not available)" + # Run viu to render the image + # -w 40: width in characters + # -h 30: height in characters + # -t: transparent background + result = subprocess.run( + ['viu', '-w', '40', '-t', image_path], + capture_output=True, + text=True, + check=True + ) + return result.stdout + + except subprocess.CalledProcessError as e: + return f"Failed to render image with viu: {e.stderr}\nPoster at: {image_path}" except Exception as e: - return f"Failed to display image at {image_path}: {e}" \ No newline at end of file + return f"Failed to display image: {e}\nPoster at: {image_path}" \ No newline at end of file diff --git a/uv.lock b/uv.lock index d2b3cf4..016a741 100644 --- a/uv.lock +++ b/uv.lock @@ -462,7 +462,7 @@ wheels = [ [[package]] name = "renamer" -version = "0.6.12" +version = "0.7.1" source = { editable = "." } dependencies = [ { name = "langcodes" },