From 7fa742ec20c5f20082e9912222e8674aae5f8038 Mon Sep 17 00:00:00 2001 From: Shravan Mandava Date: Wed, 31 Dec 2025 13:54:50 +0000 Subject: [PATCH] Add Song Duration --- src/musefetch/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/musefetch/__main__.py b/src/musefetch/__main__.py index d6792c5..46fb4c4 100644 --- a/src/musefetch/__main__.py +++ b/src/musefetch/__main__.py @@ -30,11 +30,15 @@ def main(): cover = from_url(metadata.get("mpris:artUrl", "")) cover.height = 15 + duration = player.Get("org.mpris.MediaPlayer2.Player", "Position") / 1_000_000 + length = metadata.get("mpris:length", 0) / 1_000_000 + songdata = [ f"Title: {metadata.get('xesam:title', 'Unknown')}", f"Artist(s): {', '.join(metadata.get('xesam:artist', ['Unknown']))}", f"Album: {metadata.get('xesam:album', 'Unknown')}", f"Playing: {playing}", + f"{int(duration // 60)}:{int(duration % 60):02d} / {int(length // 60)}:{int(length % 60):02d}", ] img_lines = str(cover).splitlines()