From 1dc2b932a1c7ad2f17e4a3485f57fc6eb3f22548 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Fri, 28 Feb 2020 17:57:10 -0800 Subject: [PATCH] Find more types of cover art files Find cover art files with different names/extensions by matching the same files as mpDris2. --- kunst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/kunst b/kunst index b447bbc..bd0ba64 100755 --- a/kunst +++ b/kunst @@ -138,23 +138,30 @@ update_cover() { fi ARTLESS=false else - DIR="$MUSIC_DIR$(dirname "$(mpc current -f %file%)")" + DIR="$MUSIC_DIR/$(dirname "$(mpc current -f %file%)")" if [ ! $SILENT ];then echo "kunst: inspecting $DIR" fi # Check if there is an album cover/art in the folder. # Look at issue #9 for more details - for CANDIDATE in "$DIR/cover."{png,jpg}; do + # use same regex to find album art as mpDris2 + candidates=$( + find "$DIR" -type f \ + | grep -iE '/(album|cover|\.?folder|front).*\.(gif|jpeg|jpg|png)' + ) + while read -r CANDIDATE; do if [ -f "$CANDIDATE" ]; then STATUS=0 - ARTLESS=false - convert "$CANDIDATE" $COVER &> /dev/null + export ARTLESS=false + convert "$CANDIDATE" $COVER + ls -l $COVER if [ ! $SILENT ];then - echo "kunst: found cover.png" + echo "kunst: found cover $CANDIDATE" fi + break fi - done + done <<< "$candidates" # use here string so loop changes vars in main process fi if [ $STATUS -ne 0 ];then