32 lines
718 B
Bash
Executable File
32 lines
718 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
IDENTIFYER="/tmp/mprisArtUrl_"
|
|
|
|
album_art=$(playerctl metadata mpris:artUrl 2> /dev/null)
|
|
if [[ -z $album_art ]]
|
|
then
|
|
# spotify is dead, we should die too.
|
|
exit 1
|
|
fi
|
|
canidate="$IDENTIFYER$(echo "$album_art" | awk -F '/' '{ print $NF }')"
|
|
# if the url is not empty, we should download the image.
|
|
if [[ $album_art == http* ]]
|
|
then
|
|
if [[ -f "$canidate" ]]
|
|
then
|
|
# if the file exists, we should use it.
|
|
album_art="$canidate"
|
|
else
|
|
# if the file does not exist, we should download it.
|
|
curl -s -o "$canidate" "${album_art}"
|
|
album_art="$canidate"
|
|
if [[ $! -ne 0 ]]
|
|
then
|
|
# exit on fail
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo ${album_art}
|