ncmpcpp-ueberzug
ncmpcpp-ueberzug copied to clipboard
Support for Mopidy-Spotify cover art
I like what you did very much! Thank you for that... I was using conky to grab lyrics and coverart with ncmpcpp, but what you did is much cooler ; ).
Attach is a piece of code I added ( not very professional I'm afraid but works) to yours that grabs covers through mpris, you might want to consider to better incorporate it :
# Determain audio source; Local or Spotify
MOD="$(mpc --format %file% current | cut -c1-7)"
find_cover_image() {
# If audio source is 'potify' we grab cocer art using mpris
IMGURL=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mopidy /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' | grep -E -A 1 "artUrl" | grep -E -v "artUrl"| cut -b 44- | cut -d '"' -f 1)
if [ "$MOD" = "spotify" ]; then
wget -q -O "/tmp/mpd_cover.jpg" "$IMGURL" &&
cover_path="/tmp/mpd_cover.jpg" && return
fi
# we check if the audio file has an embedded album art
ext="$(mpc --format %file% current | sed 's/^.*\.//')"
if [ "$ext" = "flac" ]; then
# since FFMPEG cannot export embedded FLAC art we use metaflac
metaflac --export-picture-to=/tmp/mpd_cover.jpg \
"$(mpc --format "$music_library"/%file% current)" &&
cover_path="/tmp/mpd_cover.jpg" && return
else
ffmpeg -y -i "$(mpc --format "$music_library"/%file% | head -n 1)" \
/tmp/mpd_cover.jpg &&
cover_path="/tmp/mpd_cover.jpg" && return
fi
# If no embedded art was found we look inside the music file's directory
album="$(mpc --format %album% current)"
file="$(mpc --format %file% current)"
album_dir="${file%/*}"
album_dir="$music_library/$album_dir"
found_covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f \
-iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\\(jpe?g\|png\|gif\|bmp\)" \; )"
cover_path="$(echo "$found_covers" | head -n1)"
if [ -n "$cover_path" ]; then
return
fi
# If we still failed to find a cover image, we use the fallback
if [ -z "$cover_path" ]; then
cover_path=$fallback_image
fi
}
That's an amazing Idea. Maybe you open a pull request for him to merge your idea. It's morge the git way :)
That's awesome!! Thanks for sharing @avma !
Just in case anyone else use this block of code and happens to have the same problem, the album art wouldn't always update. In fact, for certain albums, I can see the file in the tmp directory, but it wasn't updating in ncmpcpp. Changing wget -q -O...
to curl -q --output...
Solved it for me. No idea why this would matter. Maybe download speeds make a difference?
Not sure, they both works for me just fine and my download speeds is nothing to write hoe about ;-
anyway I do hope ncmpcpp officially adds something like this to their package.
@avma Sorry for not attending to this repo but thank you so much for making this.