summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2014-08-25 22:09:24 +0200
committerRasmus Steinke <rasi@xssn.at>2014-08-25 22:09:24 +0200
commita560dff0c8d3626fbe5cd95d955b40f2847f05ba (patch)
tree0d5616d26d74a1aab4e42a0ebdd42ee732317eca /clerk
parent6cea7b9e64b8ba86556bc203b558acda3d3a68ad (diff)
downloadperl-app-clerk-a560dff0c8d3626fbe5cd95d955b40f2847f05ba.tar.gz
perl-app-clerk-a560dff0c8d3626fbe5cd95d955b40f2847f05ba.tar.xz
fixed duplicate entries in database
Diffstat (limited to 'clerk')
-rw-r--r--clerk32
1 files changed, 17 insertions, 15 deletions
diff --git a/clerk b/clerk
index 73c1f8a..99f5c0d 100644
--- a/clerk
+++ b/clerk
@@ -675,20 +675,23 @@ currentTracksInsert () {
done < <(echo -e "0 Return to current Artist Menu\n---\nAdding Mode: Insert\n---\n$(mppc search artist "$(mpc current -f %artist%)" --format "{album} $seperator {track} $seperator {title}")" | dmenu_t -p "Tracks by $(mpc current --format '%artist%') > ")
}
+escapeSql() {
+ echo ${1//\'/\'\'}
+}
rateAlbum () {
artist="$(mpc current -f %artist%)"
album="$(mpc current -f %album%)"
date="$(mpc current -f %date%)"
- directory="$(dirname $(mpc current -f %file%))"
- ratings="$(seq $maxratings | dmenu_t -p "Select Rating: > ")"
- date=${date//\'/\\\'}
- artist=${artist//\'/\\\'}
- album=${album//\'/\\\'}
- directory=${directory//\'/\\\'}
- rating=${ratings//\'/\\\'}
-
- if [ ratings = "" ]; then
+ directory="$(dirname "$(mpc current -f %file%)")"
+ rating="$(seq $maxratings | dmenu_t -p "Select Rating: > ")"
+ date=$(escapeSql "$date")
+ artist=$(escapeSql "$artist")
+ album=$(escapeSql "$album")
+ directory=$(escapeSql "$directory")
+ rating=$(escapeSql "$rating")
+
+ if [ rating = "" ]; then
exit
else
cd $HOME/.config/clerk/ratings
@@ -713,8 +716,8 @@ rateAlbum () {
fi
cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
fi
- notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %album%") with $ratings"
cd $HOME/.config/clerk/ratings
+ notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %album%") with $ratings"
sqlite3 ../ratings.db "insert or replace into albums (date, artist, album, directory, rating) values ('$date', '$artist', '$album', '$directory', '$rating')"
fi
ratingPrompt
@@ -811,12 +814,11 @@ loadRandomRatedTracks () {
loadRandomRating () {
- cd "$music_path"
- ratings_min="$(echo " " | dmenu_t -p "Minimum Rating > " | xargs echo)"
- ratings_max="$(echo " " | dmenu_t -p "Maximum Rating > " | xargs echo)"
+ cd $HOME/.config/clerk
+ rating="$(seq $maxratings | dmenu_t -p "Minimum Rating > " | xargs echo)"
mpc clear
- grep -lF "$(seq $ratings_min $ratings_max)" **/rating.txt | sed -e 's/\/rating.txt.*//g' | shuf -n 1 | while read line; do
- mpc add "$line" && mpc play; done
+ for albums in "$(sqlite3 ratings.db "select directory from albums where rating >= $rating;")"; do echo "$albums"; done| shuf -n 1| mpc add
+ mpc play
}
playRandomAlbum () {