summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2014-08-25 22:23:56 +0200
committerRasmus Steinke <rasi@xssn.at>2014-08-25 22:23:56 +0200
commitb9470977884e48cd12d278060b9de69c8db263e0 (patch)
tree00769d3b02e3670ca75d4bcf21888c13432434ea /clerk
parent9c4341fe07b8edd1eb6d0d087682094ec585d441 (diff)
downloadperl-app-clerk-b9470977884e48cd12d278060b9de69c8db263e0.tar.gz
perl-app-clerk-b9470977884e48cd12d278060b9de69c8db263e0.tar.xz
updated rateTrack function
Diffstat (limited to 'clerk')
-rw-r--r--clerk26
1 files changed, 19 insertions, 7 deletions
diff --git a/clerk b/clerk
index 99f5c0d..06a99bd 100644
--- a/clerk
+++ b/clerk
@@ -230,14 +230,14 @@ updateDB () {
echo "$rating_split" | while read ratings; do
rating=$(echo "$ratings" | cut -d '/' -f1)
rating_max=$(echo "$ratings" | cut -d '/' -f2)
- title=$(echo "$ratings" | cut -d ' ' -f2-)
+ file=$(echo "$ratings" | cut -d ' ' -f2-)
date=${date//\'/\\\'}
artist=${artist//\'/\\\'}
album=${album//\'/\\\'}
directory=${directory//\'/\\\'}
title=${title//\'\\\'}
rating=${rating//\'/\\\'}
- sqlite3 ../ratings.db "insert or replace into tracks (date, artist, album, directory, rating) values ('$date', '$artist', '$album', '$directory/$title', '$rating')"
+ sqlite3 ../ratings.db "insert or replace into tracks (date, artist, album, directory, rating) values ('$date', '$artist', '$album', '$directory/$file', '$rating')"
done
done
ratingPrompt
@@ -717,14 +717,25 @@ rateAlbum () {
cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
fi
cd $HOME/.config/clerk/ratings
- notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %album%") with $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')"
fi
ratingPrompt
}
rateTrack () {
- ratings="$(seq $track_maxratings | rofi -dmenu -p "Select Rating: > ")"
+ artist="$(mpc current -f %artist%)"
+ album="$(mpc current -f %album%)"
+ date="$(mpc current -f %date%)"
+ directory="$(dirname "$(mpc current -f %file%)")"
+ file="$(mpc current -f %file% | awk -F '/' '{ print $NF }')"
+ rating="$(seq $track_maxratings | dmenu_t -p "Select Rating: > ")"
+ date=$(escapeSql "$date")
+ artist=$(escapeSql "$artist")
+ album=$(escapeSql "$album")
+ directory=$(escapeSql "$directory")
+ rating=$(escapeSql "$rating")
+
if [ ratings = "" ]; then
exit
else
@@ -743,7 +754,7 @@ rateTrack () {
sed -i "/$cur_file/d" "$(mpc current -f %artist%--%date%--%album%).ratings"
echo "File already rated. Changing Rating..."
fi
- echo "rating=$ratings/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ echo "rating=$rating/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
fi
if [[ "$music_dir_access" == "yes" ]]; then
cd "$music_path"
@@ -753,8 +764,9 @@ rateTrack () {
fi
cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
fi
- notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %title%") with $ratings"
- updateDB
+ cd $HOME/.config/clerk/ratings
+ notify-send "clerk" "Rated $(mpc current -f "%$mpd_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
}