diff options
Diffstat (limited to 'clerk')
-rw-r--r-- | clerk | 61 |
1 files changed, 35 insertions, 26 deletions
@@ -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" } |