summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2014-08-25 23:41:04 +0200
committerRasmus Steinke <rasi@xssn.at>2014-08-25 23:41:04 +0200
commit236a92c1cafe9fd1f2777cf2c9b6d6a4d77923e1 (patch)
tree72adc13bb1094d81bf4a440cb16de3e238f621fb /clerk
parentac4443c68007f8ece58ed414105bd0edc30d156c (diff)
downloadperl-app-clerk-236a92c1cafe9fd1f2777cf2c9b6d6a4d77923e1.tar.gz
perl-app-clerk-236a92c1cafe9fd1f2777cf2c9b6d6a4d77923e1.tar.xz
make ratings file respect mpd_artist variable
Diffstat (limited to 'clerk')
-rw-r--r--clerk40
1 files changed, 21 insertions, 19 deletions
diff --git a/clerk b/clerk
index 7dfea9b..b1c4b69 100644
--- a/clerk
+++ b/clerk
@@ -683,6 +683,7 @@ escapeSql() {
rateAlbum () {
artist="$(mpc current -f %artist%)"
+ albumartist=$(mpc current -f %albumartist%)
album="$(mpc current -f %album%)"
date="$(mpc current -f %date%)"
directory="$(dirname "$(mpc current -f %file%)")"
@@ -697,30 +698,30 @@ rateAlbum () {
exit
else
cd $HOME/.config/clerk/ratings
- if [[ -a "$(mpc current -f %artist%--%date%--%album%).ratings" ]]; then
+ if [[ -a "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings" ]]; then
echo "Ratings file present, using it"
else
- echo "artist="$(mpc current --format %artist%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "album="$(mpc current --format %album%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "date="$(mpc current --format %date%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "directory="$(dirname "$(mpc current --format %file%)")"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ echo "artist="$(mpc current --format %artist%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "album="$(mpc current --format %album%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "date="$(mpc current --format %date%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "directory="$(dirname "$(mpc current --format %file%)")"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
fi
if grep "album_rating=" "$(mpc current -f %artist%--%date%--%album%).ratings" > /dev/null; then
- sed -i "/album_rating/d" "$(mpc current -f %artist%--%date%--%album%).ratings"
+ sed -i "/album_rating/d" "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
echo "Album already rated. Changing Rating"
fi
- echo "album_rating=$ratings/$maxratings" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ echo "album_rating=$ratings/$maxratings" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
if [[ "$music_dir_access" == "yes" ]]; then
cd "$music_path"
cd "$(dirname "$(mpc current -f %file%)")"
if [[ "$(pwd)" == */"$cd_divider"* ]]; then
cd ..
fi
- cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
+ cp $HOME/.config/clerk/ratings/"$(mpc current -f %$mpd_artist%--%date%--%album%).ratings" .
fi
cd $HOME/.config/clerk/ratings
notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %album%") with $rating"
- sqlite3 ../ratings.db "insert or replace into albums (date, artist, album, directory, rating) values ('$date', '$artist', '$album', '$directory', '$rating')"
+ sqlite3 ../ratings.db "insert or replace into albums (date, artist, album, directory, rating) values ('$date', '$mpd_artist', '$album', '$directory', '$rating')"
fi
ratingPrompt
}
@@ -728,6 +729,7 @@ rateAlbum () {
rateTrack () {
artist="$(mpc current -f %artist%)"
album="$(mpc current -f %album%)"
+ albumartist="$(mpc current -f %albumartist%)"
date="$(mpc current -f %date%)"
directory="$(dirname "$(mpc current -f %file%)")"
file="$(mpc current -f %file% | awk -F '/' '{ print $NF }')"
@@ -744,19 +746,19 @@ rateTrack () {
cur_artist="$(mpc current -f %artist%)"
cur_file="$(basename "$(mpc current -f %file%)")"
cd $HOME/.config/clerk/ratings
- if [[ -a "$(mpc current -f %artist%--%date%--%album%).ratings" ]]; then
+ if [[ -a "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings" ]]; then
echo "Ratings file present, using it"
else
- echo "artist="$(mpc current --format %artist%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "album="$(mpc current --format %album%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "date="$(mpc current --format %date%)"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
- echo "directory="$(dirname "$(mpc current --format %file%)")"" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ echo "artist="$(mpc current --format %artist%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "album="$(mpc current --format %album%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "date="$(mpc current --format %date%)"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
+ echo "directory="$(dirname "$(mpc current --format %file%)")"" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
fi
- if grep "$cur_file" "$(mpc current -f %artist%--%date%--%album%).ratings" > /dev/null; then
- sed -i "/$cur_file/d" "$(mpc current -f %artist%--%date%--%album%).ratings"
+ if grep "$cur_file" "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings" > /dev/null; then
+ sed -i "/$cur_file/d" "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
echo "File already rated. Changing Rating..."
fi
- echo "rating=$rating/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ echo "rating=$rating/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %$mpd_artist%--%date%--%album%).ratings"
fi
if [[ "$music_dir_access" == "yes" ]]; then
cd "$music_path"
@@ -764,10 +766,10 @@ rateTrack () {
if [[ "$(pwd)" == */"$cd_divider"* ]]; then
cd ..
fi
- cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
+ cp $HOME/.config/clerk/ratings/"$(mpc current -f %$mpd_artist%--%date%--%album%).ratings" .
fi
cd $HOME/.config/clerk/ratings
- notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %title%") with $rating"
+ notify-send "clerk" "Rated $(mpc current -f "%artist% - %title%") with $rating"
sqlite3 ../ratings.db "insert or replace into tracks (date, artist, album, directory, rating) values ('$date', '$artist', '$album', '$directory/$file', '$rating')"
ratingPrompt
}