Skip to content

Commit

Permalink
do not downgrade karma on pause-song
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhangui committed Dec 24, 2024
1 parent 88d4605 commit c590d55
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/mpdev-c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:

steps:
- name: extra_packages
run: if [ "${OS}" = "macos-latest" ]; then brew install automake autoconf libtool pkgconfig sqlite3 openssl; fi
run: |
if [ "${OS}" = "ubuntu-latest" ]; then sudo apt-get update;sudo apt-get install libsqlite3-dev; fi
if [ "${OS}" = "macos-latest" ]; then brew install automake autoconf libtool pkgconfig sqlite3 openssl; fi
env:
OS: ${{ matrix.host }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mpdev-obs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: install_qmail
run: |
sudo apt-get update; sudo apt-get install libssl-dev libmysqlclient-dev
sudo apt-get update; sudo apt-get install libssl-dev libmysqlclient-dev libsqlite3-dev
cd libqmail; ./default.configure; make; sudo make install-strip
- name: prepare obs
run: /bin/rm -rf libqmail;./prepare_obs mpdev
Expand Down
2 changes: 2 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Release 1.1 Start 30/06/2022 End --/--/----
27. mpdplaylist.in: fixed command line arguments having space
- 01/08/2024
28. karma.in: fixes for MacOS
- 23/12/2024
29. player.in: do not downgrade karma on pause song

* 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
5 changes: 4 additions & 1 deletion karma.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: karma.in,v 1.13 2024-04-09 23:24:45+05:30 Cprogrammer Exp mbhangui $
# $Id: karma.in,v 1.14 2024-12-23 19:08:21+05:30 Cprogrammer Exp mbhangui $
#

get_mpd_conf_value()
Expand Down Expand Up @@ -335,6 +335,9 @@ fi
exit 0
#
# $Log: karma.in,v $
# Revision 1.14 2024-12-23 19:08:21+05:30 Cprogrammer
# fix for darwin
#
# Revision 1.13 2024-04-09 23:24:45+05:30 Cprogrammer
# display scrobble command if running with a tty
#
Expand Down
25 changes: 14 additions & 11 deletions player.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
#
# $Id: player.in,v 1.53 2024-03-11 16:47:18+05:30 Cprogrammer Exp mbhangui $
# $Id: player.in,v 1.54 2024-12-23 19:08:35+05:30 Cprogrammer Exp mbhangui $
#
get_mpd_conf_value()
{
Expand Down Expand Up @@ -247,7 +247,7 @@ update_song()
no_db_update=1
fi
fi
if [ " $state" = " now-playing" ] ; then
if [ "$state" = "now-playing" ] ; then
if [ -f $MPDEV_TMPDIR/start_time.$csum ] ; then
START_TIME=`cat $MPDEV_TMPDIR/start_time.$csum`
fi
Expand Down Expand Up @@ -359,7 +359,7 @@ update_song()
fi
prev_last_played=$(get_stats_last_played "$uri")
if [ $VERBOSE -gt 0 ] ; then
if [ ! -f $MPDEV_TMPDIR/rating.$csum -a " $state" = " now-playing" ] ; then
if [ ! -f $MPDEV_TMPDIR/rating.$csum -a "$state" = "now-playing" ] ; then
if [ $gnu_date -eq 1 ] ; then
echo -n "NewSong [$csum] Start=$START_TIME [`date +"%Y-%m-%d %H:%M:%S" --date=@"$START_TIME"`] "
else
Expand Down Expand Up @@ -426,15 +426,15 @@ update_song()
fi
if [ -n "$SCROBBLE_LIBREFM" -o -n "$SCROBBLE_LASTFM" ] ; then
if [ ! -f $MPDEV_TMPDIR/scrobble.$csum ] ; then
if [ ! " $PLAYER_STATE" = " pause" -a ! " $PLAYER_STATE" = " stop" ] ; then
if [ ! "$PLAYER_STATE" = "pause" -a ! "$PLAYER_STATE" = "stop" ] ; then
scrobble
touch $MPDEV_TMPDIR/scrobble.$csum
fi
fi
fi
;;
"end-song"|"pause-song")
if [ " $state" = " end-song" ] ; then
if [ "$state" = "end-song" ] ; then
if [ -z "$END_TIME" ] ; then
exit 0
fi
Expand All @@ -454,7 +454,7 @@ update_song()
fi
if [ -n "$SONG_PLAYED_DURATION" ] ; then
percent=$(awk "BEGIN { pc=100*${SONG_PLAYED_DURATION}/${SONG_DURATION}; i=int(pc); print (pc-i<0.5)?i:i+1 }")
if [ " $percent" = " 0.0" ] ; then
if [ "$percent" = "0.0" ] ; then
percent=0
fi
var=$(awk 'BEGIN {print ('$percent\>=$MIN_PLAY_PERCENT')}')
Expand All @@ -471,9 +471,9 @@ update_song()
else
if [ -n "$SONG_PLAYED_DURATION" ] ; then
if [ $var -eq 0 ] ; then
downgrade_karma "$uri"
fi
if [ $var -eq 0 ] ; then
if [ "$state" = "end-song" ] ; then
downgrade_karma "$uri"
fi
echo "SONG [$csum] "$percent"% played duration=$SONG_PLAYED_DURATION secs (partial)"
else
echo "SONG [$csum] "$percent"% played duration=$SONG_PLAYED_DURATION secs (full)"
Expand Down Expand Up @@ -502,7 +502,7 @@ update_song()
fi
fi
fi
if [ " $state" = " end-song" ] ; then
if [ "$state" = "end-song" ] ; then
if [ $VERBOSE -gt 0 ] ; then
if [ -n "$END_TIME" ] ; then
if [ $gnu_date -eq 1 ] ; then
Expand All @@ -520,7 +520,7 @@ update_song()
$MPDEV_TMPDIR/start_time.$csum $MPDEV_TMPDIR/rating.$csum \
$MPDEV_TMPDIR/stats_playcount.$csum \
$MPDEV_TMPDIR/percent_played $MPDEV_TMPDIR/pcount.$csum $MPDEV_TMPDIR/end.$csum
elif [ " $state" = " pause-song" ] ; then
elif [ "$state" = "pause-song" ] ; then
if [ $VERBOSE -gt 0 ] ; then
if [ -n "$END_TIME" ] ; then
if [ $gnu_date -eq 1 ] ; then
Expand Down Expand Up @@ -598,6 +598,9 @@ fi
exit 0

# $Log: player.in,v $
# Revision 1.54 2024-12-23 19:08:35+05:30 Cprogrammer
# do now downgrade karma on pause-song
#
# Revision 1.53 2024-03-11 16:47:18+05:30 Cprogrammer
# removed rompr
#
Expand Down

0 comments on commit c590d55

Please sign in to comment.