Skip to content

Commit

Permalink
optimized where it checks the songinfo for being the same before re-f…
Browse files Browse the repository at this point in the history
…inding the cover
  • Loading branch information
uriel1998 committed Nov 14, 2023
1 parent 6f4ed05 commit 04f4b76
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions vindauga.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,28 @@ function get_coverart () {
SONGSTRING=$(mpc current --format "%artist% - %album% - %title%")
fi
fi
if [ -f "${SONGFILE}" ];then
SONGDIR=$(dirname "$(readlink -f "${SONGFILE}")")

if [ -f "$SONGDIR"/folder.jpg ];then
COVERFILE="$SONGDIR"/folder.jpg
else
if [ -f "$SONGDIR"/cover.jpg ];then
COVERFILE="$SONGDIR"/cover.jpg
SONGCHECK=$(head -1 "${VINDAUGA_CACHE}/songinfo")
if [ "${SONGSTRING}" != "${SONGCHECK}" ];then
if [ -f "${SONGFILE}" ];then
SONGDIR=$(dirname "$(readlink -f "${SONGFILE}")")

if [ -f "$SONGDIR"/folder.jpg ];then
COVERFILE="$SONGDIR"/folder.jpg
else
if [ -f "$SONGDIR"/cover.jpg ];then
COVERFILE="$SONGDIR"/cover.jpg
fi
fi
fi
if [ "$COVERFILE" == "" ];then
COVERFILE=${DEFAULT_COVER}
fi
echo "${SONGSTRING}" > "${VINDAUGA_CACHE}/songinfo"
TEMPFILE3=$(mktemp)
convert "${COVERFILE}" -resize "600x600" "${TEMPFILE3}"
round_rectangles "${TEMPFILE3}" "${VINDAUGA_CACHE}/nowplaying.album.png"
rm "${TEMPFILE3}"
fi
echo "${SONGSTRING}"
if [ "$COVERFILE" == "" ];then
COVERFILE=${DEFAULT_COVER}
fi
echo "${SONGSTRING}" > "${VINDAUGA_CACHE}/songinfo"
TEMPFILE3=$(mktemp)
convert "${COVERFILE}" -resize "600x600" "${TEMPFILE3}"
round_rectangles "${TEMPFILE3}" "${VINDAUGA_CACHE}/nowplaying.album.png"
rm "${TEMPFILE3}"
}

display_help() {
Expand Down

0 comments on commit 04f4b76

Please sign in to comment.