summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2014-08-24 21:54:24 +0200
committerRasmus Steinke <rasi@xssn.at>2014-08-24 21:54:24 +0200
commit95a67f78f63abbc72e29f12f3559bbca87d4c936 (patch)
tree6afa10472ff4a8237c278dc42c377a99c1d87b6b /clerk
parent6bf726bfdaa7643d6811cb99bfa4950741694b86 (diff)
downloadperl-app-clerk-95a67f78f63abbc72e29f12f3559bbca87d4c936.tar.gz
perl-app-clerk-95a67f78f63abbc72e29f12f3559bbca87d4c936.tar.xz
merged tracks and album ratings file
Diffstat (limited to 'clerk')
-rw-r--r--clerk61
1 files changed, 35 insertions, 26 deletions
diff --git a/clerk b/clerk
index 3933aff..a2b4cf6 100644
--- a/clerk
+++ b/clerk
@@ -616,26 +616,28 @@ rateAlbum () {
if [ ratings = "" ]; then
exit
else
+ cd $HOME/.config/clerk/ratings
+ if ls "$(mpc current -f %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"
+ 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"
+ echo "Album already rated. Changing Rating"
+ fi
+ echo "album_rating=$ratings/$maxratings" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
if [[ "$music_dir_access" == "yes" ]]; then
cd "$music_path"
- cd "$music_path"
cd "$(dirname "$(mpc current -f %file%)")"
if [[ "$(pwd)" == */"$cd_divider"* ]]; then
cd ..
- else echo " "
fi
- rm -f "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$ratings/$maxratings" > "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f "%$mpd_artist%")" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f '%album%')" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f '%date%')" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
+ cp $HOME/.config/clerk/ratings/"$(mpc current -f %artist%--%date%--%album%).ratings" .
fi
- cd $HOME/.config/clerk/ratings
- rm -f "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$ratings/$maxratings" > "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f "%$mpd_artist%")" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f '%album%')" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
- echo "$(mpc current -f '%date%')" >> "$(mpc current -f %artist%--%date%--%album%).albumrating"
notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %album%") with $ratings"
fi
}
@@ -647,23 +649,30 @@ rateTrack () {
else
cur_artist="$(mpc current -f %artist%)"
cur_file="$(basename "$(mpc current -f %file%)")"
- if [[ "$music_dir_access" == "yes" ]]; then
- cd "$music_path"
- cd "$(dirname "$(mpc current -f %file%)")"
- if grep "$cur_file" "$(mpc current -f %artist%--%date%--%album%).trackratings" > /dev/null; then
- sed -i "/$cur_file/d" "$(mpc current -f %artist%--%date%--%album%).trackratings"
- echo "File already rated. Changing Rating..."
- fi
- echo "$ratings/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).trackratings"
- fi
cd $HOME/.config/clerk/ratings
- if grep "$cur_file" "$(mpc current -f %artist%--%date%--%album%).trackratings" > /dev/null; then
- sed -i "/$cur_file/d" "$(mpc current -f %artist%--%date%--%album%).trackratings"
+ if ls "$(mpc current -f %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"
+ 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"
echo "File already rated. Changing Rating..."
fi
- echo "$ratings/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).trackratings"
- notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %title%") with $ratings"
+ echo "rating=$ratings/$track_maxratings $(echo "$cur_file")" >> "$(mpc current -f %artist%--%date%--%album%).ratings"
+ fi
+ 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" .
fi
+ notify-send "clerk" "Rated $(mpc current -f "%$mpd_artist% - %title%") with $ratings"
}