From 95a67f78f63abbc72e29f12f3559bbca87d4c936 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Sun, 24 Aug 2014 21:54:24 +0200 Subject: merged tracks and album ratings file --- clerk | 61 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'clerk') 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" } -- cgit v1.2.3-24-g4f1b