From 968d9587b63f114765efebebb9ceb24e3870743e Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 18 Mar 2026 23:08:13 +1100 Subject: [PATCH] feat: Add support for specifying cli spotify image size --- ascii_art.py | 4 ++-- blueprints/spotify.py | 5 ++++- templates/spotify.ascii | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ascii_art.py b/ascii_art.py index 63ee34a..05fb22f 100644 --- a/ascii_art.py +++ b/ascii_art.py @@ -48,8 +48,8 @@ def image_url_to_ascii(url, new_width=40): # Since we are using '██' (double width), we effectively make each "cell" square. # So we can just scale by aspect ratio directly without additional correction factor. new_height = int(aspect_ratio * new_width) - if new_height > 60: - new_height = 60 + if new_height > height: + new_height = height new_width = int(new_height / aspect_ratio) # Resize and ensure RGB mode diff --git a/blueprints/spotify.py b/blueprints/spotify.py index 41df344..d99ff82 100644 --- a/blueprints/spotify.py +++ b/blueprints/spotify.py @@ -106,9 +106,12 @@ def callback(): def currently_playing(): """Public endpoint showing your current track.""" track = get_playing_spotify_track() + # Get terminal width for ASCII art scaling + width = request.args.get("width", default=40, type=int) + if isCLI(request): if "album_art" in track: - track["ascii_art"] = image_url_to_ascii(track["album_art"], new_width=40) + track["ascii_art"] = image_url_to_ascii(track["album_art"], new_width=width) return render_template("spotify.ascii", track=track) # Render a simple HTML page for browsers diff --git a/templates/spotify.ascii b/templates/spotify.ascii index 3db01eb..337764a 100644 --- a/templates/spotify.ascii +++ b/templates/spotify.ascii @@ -18,4 +18,5 @@ URL: {{ track.url }} Progress: {{ track.progress_ms // 60000 }}:{{ '%02d' % ((track.progress_ms // 1000) % 60) }} / {{ track.duration_ms // 60000 }}:{{ '%02d' % ((track.duration_ms // 1000) % 60) }} Status: {{ 'Playing' if track.is_playing else 'Paused' }} +Note: Specify width with ?width=80 (default 40) {% endif %}