From f5980a987f1294704bfa911b0de5d018cf78d02d Mon Sep 17 00:00:00 2001 From: deepjyoti30 Date: Tue, 19 Feb 2019 01:27:53 +0530 Subject: [PATCH] Added function to get albumcover online --- kunst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/kunst b/kunst index c1556c7..25ce1fa 100755 --- a/kunst +++ b/kunst @@ -17,6 +17,25 @@ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 EOF +get_cover_online() { + # Try to get the album cover online from api.deezer.com + API_URL="http://api.deezer.com/search/autocomplete?q=$(mpc current)" && ur=${ur//' '/'%20'} + + # extract the albumcover from the json returned + IMG_URL=$(curl -s "$API_URL" | jq -r '.playlists.data[0] | .picture_big') + + if [ $IMG_URL = '' ] || [ $IMG_URL = 'null' ];then + echo "error: Cover not found online" + ARTLESS=true + else + echo "kunst: Cover found online" + wget -o $COVER $IMG_URL + ARTLESS=false + fi + +} + + update_cover() { # extract the album art from the mp3 file and dont show the messsy # output of ffmpeg @@ -31,7 +50,8 @@ update_cover() { ARTLESS=false else echo "error: file does not have an album art" - ARTLESS=true + get_cover_online + # ARTLESS=true return fi