diff options
author | Rasmus Steinke <rasi@xssn.at> | 2014-12-07 10:25:04 +0100 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2014-12-07 10:25:04 +0100 |
commit | d59cd9057b33abe3b39780a8559fe0db858c1e3c (patch) | |
tree | 9a15bca5d93f460291e7291d15309fc5f0e3fd6e | |
parent | c3d90719d6aa00b7f47a410f21e14dd7e6b3a1e9 (diff) | |
download | perl-app-clerk-d59cd9057b33abe3b39780a8559fe0db858c1e3c.tar.gz perl-app-clerk-d59cd9057b33abe3b39780a8559fe0db858c1e3c.tar.xz |
added example script for import of ratings into mpds sticker database
-rwxr-xr-x | sticker_import.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sticker_import.sh b/sticker_import.sh new file mode 100755 index 0000000..1d3742d --- /dev/null +++ b/sticker_import.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# example script to import clerks flat rating files back into mpds sticker +# database. This example is for albumratings and works for flac, ogg and mp3. +# files. music_path has to be set in clerks config file. +# If you have a nicer script to do this, let me know :) + +source $HOME/.config/clerk/config + +findfiles () { +if [[ "$1" == "flac" ]] || [[ "$1" == "ogg" ]]; then + cd "$(dirname "$2")" + info="$(mutagen-inspect 01-*.flac)" + artist="$(echo "$info" | grep "^ARTIST=" | awk -F "=" '{ print $2 }')" + album="$(echo "$info" | grep "^ALBUM=" | awk -F "=" '{ print $2 }')" + date="$(echo "$info" | grep "^DATE=" | awk -F "=" '{ print $2 }')" + albumrating="$(grep "albumrating=" "$music_path"/"$2" | awk -F "=" '{ print $2 }')" + + if [[ -z "$(mpc find artist "$artist" album "$album" date "$date" disc "1" track "1")" ]]; then + uri="$(mpc find artist "$artist" album "$album" date "$date" track "1")" + else + uri="$(mpc find artist "$artist" album "$album" date "$date" disc "1" track "1")" + fi + mpc sticker "$uri" set albumrating "$albumrating" + +elif [[ "$1" == "mp3" ]]; then + cd "$(dirname "$2")" + info="$(mutagen-inspect 01-*.mp3)" + artist="$(echo "$info" | grep "^TPE2=" | awk -F "=" '{ print $2 }')" + album="$(echo "$info" | grep "^TALB=" | awk -F "=" '{ print $2 }')" + date="$(echo "$info" | grep "^TDRC=" | awk -F "=" '{ print $2 }')" + albumrating="$(grep "albumrating=" "$music_path"/"$2" | awk -F "=" '{ print $2 }')" + + if [[ -z "$(mpc find artist "$artist" album "$album" date "$date" disc "1" track "1")" ]]; then + uri="$(mpc find artist "$artist" album "$album" date "$date" track "1")" + else + uri="$(mpc find artist "$artist" album "$album" date "$date" disc "1" track "1")" + fi + mpc sticker "$uri" set albumrating "$albumrating" +fi +} + +cd "$music_path" +find . -name \*.albumrating | while read file; do findfiles $1 "$file"; done |