-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: music
action: commit
revision:
path_from:
revision_from: c71050f30b84af00d8c53791d301569373942f70:
path_to:
revision_to:

git.thebackupbox.net

music

git://git.thebackupbox.net/music

commit c71050f30b84af00d8c53791d301569373942f70
Author: epoch <epoch@enzo.thebackupbox.net>
Date:   Tue Sep 7 17:40:58 2021 +0000

    attempts to get amount of time played so far and song length

diff --git a/music-fileinfo b/music-fileinfo

index 1fe1fa417b0c5f7123e98f5152b76b70f832ca57..

index ..9f5f2faedf8df124909850e8344e6febdb8b52fc 100755

--- a/music-fileinfo
+++ b/music-fileinfo
@@ -1,12 +1,19 @@
 #!/bin/bash
 ext="$(printf "$1" | rev | cut -d. -f1 | rev)"
+l="$(music-length "$1" | cut -d. -f1)"
+if grep : <<< "$l" >/dev/null ;then
+  song_length="$l"
+else
+  song_length="$(elapsedtime -s $(music-length "$1" | cut -d. -f1))"
+fi
+length="$(elapsedtime -s $[$(date +%s) - $(stat -c %Z "/proc/$(cat "${PREFIX}/run/music/player.pid")")])/${song_length}"
 if [ "$ext" = "mp3" ];then
   data="$(id3v2 -R "$1")"
   #echo $data
-  artist="$(printf "%s\n" "$data" | grep '^TPE1: ' | cut '-d ' -f2-)"
-  title="$(printf "%s\n" "$data" | grep '^TIT2: ' | cut '-d ' -f2-)"
-  album="$(printf "%s\n" "$data" | grep '^TALB: ' | cut '-d ' -f2-)"
-  year="$(printf "%s\n" "$data" | grep '^TYER: ' | cut '-d ' -f2-)"
+  artist="$(printf "%s\n" "$data" | grep '^TPE1: ' | cut '-d ' -f2- | tr -s ' ' | sed 's/^ *//g;s/ *$//g')"
+  title="$(printf "%s\n" "$data" | grep '^TIT2: ' | cut '-d ' -f2- | tr -s ' ' | sed 's/^ *//g;s/ *$//g')"
+  album="$(printf "%s\n" "$data" | grep '^TALB: ' | cut '-d ' -f2- | tr -s ' ' | sed 's/^ *//g;s/ *$//g')"
+  year="$(printf "%s\n" "$data" | grep '^TYER: ' | cut '-d ' -f2- | tr -s ' ' | sed 's/^ *//g;s/ *$//g')"
 fi
 if [ "$ext" = "flac" ];then
   artist="$(metaflac --show-tag=artist "$1" | cut -d= -f2-)"
@@ -21,7 +28,7 @@ if [ "$ext" = "ogg" ];then
   year="$(vorbiscomment "$1" | grep "^DATE=" | cut -d= -f2-)"
 fi
 if [ "$artist" -a "$title" -a "$album" -a "$year" ];then
-  printf '"%s" by %s on %s (%s)\n' "$title" "$artist" "$album" "$year"
+  printf '"%s" by %s on %s (%s) [%s]\n' "$title" "$artist" "$album" "$year" "$length"
 else
-  printf "%s\n" "$1" | sed "s|$HOME/Music/||"
+  printf "%s [%s]\n" "$(printf "%s\n" "$1" | sed "s|$HOME/Music/||")" "$length"
 fi

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 16:42:14 2024