Skip to content

Commit

Permalink
updated songi
Browse files Browse the repository at this point in the history
1. display last played in days, hours, mins, secs ago
2. updated description in RPM spec and debian control
  • Loading branch information
mbhangui committed Mar 30, 2024
1 parent 44e746b commit d73dbf7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
10 changes: 8 additions & 2 deletions debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Description: MPD Event Watcher
using mpd's idle command and execs user defined script on event changes.
.
* Uses mpd's idle mode.
* Calls user $HOME/bin/player
* Calls user scripts in $HOME/.mpdev (player, playpause, output, mixer,
lcd_display)
* Sets special environment variables to pass data to the hooks.
* Optional support for scrobbling to last.fm, libre.fm through external scripts
* Included scripts:
Expand All @@ -25,6 +26,11 @@ Description: MPD Event Watcher
- player
+ saves song data to a sqlite database
+ tracks play count of songs, artist, albums and genres.
+ helps chose songs based on listening habits using mpdplaylist
+ helps choose songs based on listening habits using mpdplaylist
playlist generator
+ synchronizes rompr, stats and mpd's sticker db
- mixer
+ prints volume control value
- lcd_display
+ prints song information to a host running lcdDaemon for
display on a display with Hitachi HD44780 controller
2 changes: 2 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Release 1.1 Start 30/06/2022 End --/--/----
20. playpause: pass RATING, PLAYCOUNT env variable to lcd_display
- 04/07/2023
21. karma: added --love option to mark scrobble as loved
- 26/03/2024
22. songi: display last played in days, hours, mins, secs ago

* Thu Jun 30 2022 18:32:58 IST Manvendra Bhangui <[email protected]> 1.0-1.1%{?dist}
Release 1.0 Start 02/03/2020 End 30/06/2022
Expand Down
8 changes: 7 additions & 1 deletion mpdev.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ mpdev is a daemon, written in C, that watches a Music Player Daemon events,
using mpd's idle command and execs user defined script on event changes.

* Uses mpd's idle mode.
* Calls user scripts in $HOME/.mpdev (player, playpause, output)
* Calls user scripts in $HOME/.mpdev (player, playpause, output, mixer,
lcd_display)
* Sets special environment variables to pass data to the hooks.
* Optional support for scrobbling to last.fm, libre.fm through external scripts
* Included scripts:
Expand All @@ -64,6 +65,11 @@ using mpd's idle command and execs user defined script on event changes.
+ helps chose songs based on listening habits using mpdplaylist
playlist generator
+ synchronizes stats and mpd's sticker db
- mixer
+ prints volume control value
- lcd_display
+ prints song information to a host running lcdDaemon for
display on a display with Hitachi HD44780 controller

%prep
%autosetup
Expand Down
35 changes: 29 additions & 6 deletions songi.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh
#
# $Log: songi.in,v $
# Revision 1.6 2024-03-26 19:24:12+05:30 Cprogrammer
# display last played in days, hours, mins, secs ago
#
# Revision 1.5 2022-06-20 01:07:30+05:30 Cprogrammer
# use directories set in ./configure
#
Expand All @@ -17,7 +20,7 @@
# Initial revision
#
#
# $Id: songi.in,v 1.5 2022-06-20 01:07:30+05:30 Cprogrammer Exp mbhangui $
# $Id: songi.in,v 1.6 2024-03-26 19:24:12+05:30 Cprogrammer Exp mbhangui $
#

get_mpd_conf_value()
Expand Down Expand Up @@ -45,19 +48,39 @@ locate_file()
display_info()
{
turi=`echo $1|sed -e "s{'{''{g"`
Q="SELECT play_count,"
Q="$Q datetime(last_played, 'unixepoch', 'localtime'),"
out=$(mktemp -t mpdevXXXXXXXXXX)
Q="SELECT title,play_count,last_played,"
Q="$Q rating, karma, duration,"
Q="$Q artist, album, title, track, genre,"
Q="$Q artist, album, track, genre,"
Q="$Q date, composer, performer, disc,"
Q="$Q datetime(date_added, 'unixepoch', 'localtime'),"
Q="$Q datetime(last_modified, 'unixepoch', 'localtime')"
Q="$Q FROM song WHERE uri='$turi';"
sqlite3 -noheader -line -batch $stats_file "$Q" | sed \
-e 's{.*datetime(date_added.*){ Date Added{g' \
-e 's{.*datetime(last_modified.*){Last Updated{g' \
-e 's{.*datetime(last_played.*){ Last Played{g' \
-e 's{ {{g'
-e 's{ {{g' > $out
t1=$(sed -n 3p < $out | awk '{print $3}')
t2=$(date +%s)
diff=$(echo $t1 $t2 | awk '{printf("%d\n", $2-$1)}')
days=$(echo $diff | awk '{printf("%d\n", $1/86400)}')
hours=$(echo $diff | awk '{printf("%d\n", ($1%86400)/3600)}')
mins=$(echo $diff | awk '{printf("%d\n", ($1%3600)/60)}')
secs=$(echo $diff | awk '{printf("%d\n", $1%60)}')
last_played="$(date --date=@"$t1")\n Last Played = $days days $hours hr $mins min $secs sec ago"
t1=$(sed -n 6p < $out | awk '{print $3}')
hours=$(echo $t1 | awk '{printf("%d\n", ($1%86400)/3600)}')
mins=$(echo $t1 | awk '{printf("%d\n", ($1%3600)/60)}')
secs=$(echo $t1 | awk '{printf("%d\n", $1%60)}')
if [ "$hours" = "0" ] ; then
duration="$mins min $secs sec ($t1)"
else
duration="$hours hr $mins min $secs sec ($t1)"
fi
sed \
-e "s{last_played.*{Last Played = $last_played{g" \
-e "s{duration.*{Duration = $duration{g" < $out
/bin/rm -f $out
}

if [ $# -eq 0 ] ; then
Expand Down

0 comments on commit d73dbf7

Please sign in to comment.