Skip to content

Commit

Permalink
removed rompr
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhangui committed Mar 11, 2024
1 parent 4147232 commit 3052dd5
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 764 deletions.
10 changes: 3 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ mpdevlibexecdir=@libexecdir@/mpdev
mpdevsysconfdir=@sysconfdir@/mpdev

mpdevbin_PROGRAMS = mpdev
mpdevbin_SCRIPTS = librefm-scrobbler lastfm-scrobbler mpdplaylist romprhist \
mpdevbin_SCRIPTS = librefm-scrobbler lastfm-scrobbler mpdplaylist \
transfer_play karma songi mpdhist
mpdevlibexec_PROGRAMS = mpdev_cleanup mpdev_update
mpdevlibexec_SCRIPTS = player playpause mpdev_rename output mixer create_service \
lcd_display
noinst_DATA = mpdev.spec PKGBUILD
man_MANS = mpdplaylist.1 mpdev.1 lastfm-scrobbler.1 librefm-scrobbler.1 \
mpdev_update.1 mpdev_cleanup.1 transfer_play.1 romprhist.1 \
mpdev_update.1 mpdev_cleanup.1 transfer_play.1 \
mpdev_rename.1 karma.1 songi.1 mpdhist.1
mpdevsysconf_DATA=mpdev-release mpd_local.te
doc_DATA=LICENSE moc-scrobbler-license mpdev.changes README.md

MOSTLYCLEANFILES = mpdev player playpause librefm-scrobbler \
lastfm-scrobbler mpdplaylist choose \
create_service romprhist karma output mixer \
create_service karma output mixer \
songi mpdhist lcd_display

mpdev_SOURCES = mpdev.c
Expand Down Expand Up @@ -89,10 +89,6 @@ songi: songi.in
$(edit) $@.in > $@
chmod +x $@

romprhist: romprhist.in
$(edit) $@.in > $@
chmod +x $@

mpdhist: mpdhist.in
$(edit) $@.in > $@
chmod +x $@
Expand Down
44 changes: 6 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

mpdev helps in bulding a database of your played tracks. Along with a script `mpdplaylist`, it can generate a playlist for mpd as per your taste and mood.

You can create scripts in $HOME/.mpdev directory. The default installation installs two scripts player and playpause in $HOME/.mpdev directory for uid 1000. The scripts are adequate for most use cases. The player script can additionally be configured to update [RompЯ](https://fatg3erman.github.io/RompR/) database. The player script does the following
You can create scripts in $HOME/.mpdev directory. The default installation installs two scripts player and playpause in $HOME/.mpdev directory for uid 1000. The scripts are adequate for most use cases. The player script does the following

1. scrobbles titles to last.fm and libre.fm. You have to create API keys by running lastfm-scrobbler and librefm-scrobbler one time. You can disable scrobbling by setting DISABLE\_SCROBBLE environment variable.
2. updates play counts in the sqlite stats.db. You could write your own script and update any external database. The player script can also update the Playcounttable for [RompЯ](https://fatg3erman.github.io/RompR/) if few environment variables MYSQL\_HOST, MYSQL\_USER, MYSQL\_PASS and MYSQL\_DATABASE are configured.
3. Synchronizes the ratings in the sticker (sqlite). You could write your own script and update any external database. The player script can also update the Ratingtable for [RompЯ](https://fatg3erman.github.io/RompR/) if few environment variables MYSQL\_HOST, MYSQL\_USER, MYSQL\_PASS and MYSQL\_DATABASE are configured. You can also do automatic rating to some default value by setting an environment variable AUTO\_RATING by creating a file $HOME/.mpdev/AUTO\_RATING. If you are using supervise from deamontools (more on that below), creating an environment variable is very easy. e.g. To have an environment variable AUTO\_RATING with value 6, you just need to have a file name AUTO\_RATING in /service/mpdev/variables. The file should just have 6 as the content.
2. updates play counts in the sqlite stats.db. You could write your own script and update any external database.
3. Synchronizes the ratings in the sticker (sqlite). You could write your own script and update any external database. You can also automatically rate songs to some default value by setting an environment variable AUTO\_RATING by creating a file $HOME/.mpdev/AUTO\_RATING. If you are using supervise from deamontools (more on that below), creating an environment variable is very easy. e.g. To have an environment variable AUTO\_RATING with value 6, you just need to have a file name AUTO\_RATING in /service/mpdev/variables. The file should just have 6 as the content.
4. Update the song's karma. Karma is a number ranging from 0 to 100. If a song is skipped, it's karma is downgraded by 1. Karma can be downgraded only for songs rated less than 6 and played 5 times or less and whose karma is 50 or less. If a song is played twice within a day, it's karma is upgraded by 4. If a song is played twice within a week, it's karma is upgraded by 3. If a song is played twice within 14 days, its karma is upgraded by 2. If a song is played twice within a month, it's karma is upgraded by 1. All songs start with a default karma of 50. A song earns a permanent karma if any of the below happen

* it's karma becomes 60 or more.
Expand Down Expand Up @@ -114,7 +114,7 @@ OUTPUT_2_NAME=Scarlett 2i2 USB
OUTPUT_2_STATE=disabled
```

If you create the `stats` database, mpdev will update the last\_played field, play\_count fields in stats db. It will also update the song rating that you choose for the song. The ability to rate songs in mpd can be enabled by having the `sticker_file` keyword uncommented in `/etc/mpd.conf`. You will also need a mpd client that uses the mpd sticker command. One such player is `cantata`, which is available for all linux distros and Mac OSX. mpdev can also update [RompЯ](https://fatg3erman.github.io/RompR/) ratings and play counts and synchronize the ratings between [RompЯ](https://fatg3erman.github.io/RompR/) MySQL and sticker sqlite databases. Since mpdev runs in the background, it can keep updating [RompЯ](https://fatg3erman.github.io/RompR/), stats db play counts and history without you having to keep [RompЯ Web Frontend](https://fatg3erman.github.io/RompR/) running.
If you create the `stats` database, mpdev will update the last\_played field, play\_count fields in stats db. It will also update the song rating that you choose for the song. The ability to rate songs in mpd can be enabled by having the `sticker_file` keyword uncommented in `/etc/mpd.conf`. You will also need a mpd client that uses the mpd sticker command. One such player is `cantata`, which is available for all linux distros and Mac OSX.

The sticker database can be enabled by having the followinng entry in `/etc/mpd.conf`

Expand All @@ -127,33 +127,7 @@ sticker_file "/var/lib/mpd/sticker.db"
#
```

If you want to use mpdev to update the [RompЯ](https://fatg3erman.github.io/RompR/) db, you need to set the following variables

```
ROMPR - set this to any non-empty string (e.g. rompr)
MYSQL_HOST - set this to the host on which rompr's MySQL database is running
MYSQL_PORT - Port on which MySQL is running (usually 3306)
MYSQL_USER - User for connecting to MySQL (e.g. rompr)
MYSQL_PASS - Password for MYSQL_USER (e.g. romprdbpass)
MYSQL_DATABASE - Database name for rompr db (e.g. romprdb)
```

One can use [supervise](https://en.wikipedia.org/wiki/Daemontools) from the indimail-mta package to run this. The default rpm/debian installation of mpdev will do that for you. But it will not enable RompЯ. In case you are using RompЯ, you need to run the following commands to create the above environment variables

```
$ sudo /bin/bash
# echo rompr > /service/mpdev/variables/ROMPR
# echo 192.168.1.100 > /service/mpdev/variables/MYSQL_HOST # assuming you have MySQL database installed on 191.168.1.100
# echo 3306 > /service/mpdev/variables/MYSQL_PORT
# echo rompr > /service/mpdev/variables/MYSQL_USER
# echo romprdbpas > /service/mpdev/variables/MYSQL_PASS
# echo romprdb > /service/mpdev/variables/MYSQL_DATABASE
# echo /home/pi > /service/mpdev/variables/HOME
# echo /bin:/usr/bin > /service/mpdev/variables/PATH
# echo 6 > /service/mpdev/variables/AUTO_RATING
```

You need to restart mpdev for the new environment variables to be available to mpdev. To restart the mpdev daemon, you then just need to run the following command. `svc -d` stops the daemon, `svc -u` starts the daemon.
You need to restart mpdev for the new environment variables to be available to mpdev. To restart the mpdev daemon, you then just need to run the following command `svc -r /service/mpdev`. Below are few operations to stop, start and restart mpdev.

```
$ sudo svc -d /service/mpdev # this stops the mpdev daemon
Expand All @@ -180,13 +154,7 @@ If you want to do a source install and not have the supervise to run mpdev daemo
#!/bin/sh
while true
do
env ROMPR=rompr \
MYSQL_HOST=192.168.1.100
MYSQL_PORT=3306
MYSQL_USER=rompr
MYSQL_PASS=romprdbpass
MYSQL_DATABASE=romprdb \
HOME=/home/pi \
env HOME=/home/pi \
MPDEV_TMPDIR=/tmp/mpdev \
XDG_RUNTIME_DIR=/home/pi \
PATH=\$PATH:/usr/bin:/bin \
Expand Down
16 changes: 5 additions & 11 deletions mpdev.1
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,13 @@ running lastfm-scrobbler and librefm-scrobbler one time. You can disable
scrobbling by setting DISABLE_SCROBBLE environment variable
.sp -1
.IP \[bu]
updates play counts in the sqlite stats.db and
[RompR](https://fatg3erman.github.io/RompR/) db. RompR db update gets
enabled only when you set the \fBROMPR\fR environment variable. All db
updates get disabled if you set \fBNO_DB_UPDATE\fR environment variable.
updates play counts in the sqlite stats.db. All db updates get disabled if
you set \fBNO_DB_UPDATE\fR environment variable.
.sp -1
.IP \[bu]
Synchronizes the ratings in the sticker (sqlite),
[RompR](https://fatg3erman.github.io/RompR/) (MySQL) and the stats (sqlite)
databases. It also initializes the rating to 3 when you play an unrated
song. RompR db update gets enabled only when you set the \fBROMPR\fR
environment variable. All db updates get disabled if you set
\fBNO_DB_UPDATE\fR environment variable.
Synchronizes the ratings in the sticker (sqlite). It also initializes the
rating to 3 when you play an unrated song. All db updates get disabled if
you set \fBNO_DB_UPDATE\fR environment variable.
.PP

You can put your own script named `player` in this directory. In fact
Expand Down Expand Up @@ -219,7 +214,6 @@ OUTPUT_2_STATE=disabled
\f[B]mpdev_rename\f[](1),
\f[B]mpdev_update\f[](1),
\f[B]mpdplaylist\f[](1),
\f[B]romprhist\f[](1),
\f[B]transfer_play\f[](1)
.IP \[bu] 2
https://github.com/mbhangui/mpdev/
Expand Down
4 changes: 1 addition & 3 deletions mpdev.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using mpd's idle command and execs user defined script on event changes.
+ tracks play count of songs, artist, albums and genres.
+ helps chose songs based on listening habits using mpdplaylist
playlist generator
+ synchronizes rompr, stats and mpd's sticker db
+ synchronizes stats and mpd's sticker db

%prep
%autosetup
Expand Down Expand Up @@ -98,7 +98,6 @@ install -m 0644 %{name}-rpm.info %{buildroot}%{sysconfdir}/mpdev/%{name}-rpm.inf
%attr(755,root,root) %{_prefix}/bin/karma
%attr(755,root,root) %{_prefix}/bin/songi
%attr(755,root,root) %{_prefix}/bin/mpdhist
%attr(755,root,root) %{_prefix}/bin/romprhist
%attr(755,root,root) %{_prefix}/bin/transfer_play
%attr(755,root,root) %{_prefix}/bin/lastfm-scrobbler
%attr(755,root,root) %{_prefix}/bin/librefm-scrobbler
Expand All @@ -124,7 +123,6 @@ install -m 0644 %{name}-rpm.info %{buildroot}%{sysconfdir}/mpdev/%{name}-rpm.inf
%attr(644,root,root) %{_prefix}/share/man/man1/karma.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdhist.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/transfer_play.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/romprhist.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/lastfm-scrobbler.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/librefm-scrobbler.1.gz

Expand Down
1 change: 0 additions & 1 deletion mpdhist.1
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ Known values for OPTION are:
.EE

.SH "SEE ALSO"
romprhist(1),
mpdev(1)
9 changes: 4 additions & 5 deletions mpdhist.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: mpdhist.in,v 1.4 2022-09-26 21:15:59+05:30 Cprogrammer Exp mbhangui $
# $Id: mpdhist.in,v 1.5 2024-03-11 16:47:12+05:30 Cprogrammer Exp mbhangui $
#

usage()
Expand Down Expand Up @@ -83,10 +83,6 @@ if [ $? -ne 0 ] ; then
fi
stats_dir=$(dirname $sticker_file)
stats_file=$stats_dir/stats.db
if [ ! -f $HOME/.mpdev/rompr.conf ] ; then
echo "$HOME/.mpdev/rompr.conf missing" 1>&2
exit 1
fi
stmt=""
stmt="$stmt select id, title, artist, album, play_count, rating, "
stmt="$stmt strftime('%d-%m-%Y %H:%M:%S', datetime(last_played, 'unixepoch', 'localtime')) "
Expand All @@ -104,6 +100,9 @@ sqlite3 -header -batch -column $stats_file "$stmt" | \

#
# $Log: mpdhist.in,v $
# Revision 1.5 2024-03-11 16:47:12+05:30 Cprogrammer
# removed rompr
#
# Revision 1.4 2022-09-26 21:15:59+05:30 Cprogrammer
# removed debug statement
#
Expand Down
Loading

0 comments on commit 3052dd5

Please sign in to comment.