changed jq code to work with updated Deezer api, fixes #36

This commit is contained in:
Siddharth Dushantha 2020-06-04 17:31:49 +02:00 committed by GitHub
parent 5b927d28a5
commit dfff8d5ebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

11
kunst
View File

@ -7,7 +7,7 @@
# Dependencies: sxiv, imagemagick, bash, ffmpeg, mpc, jq, mpd # Dependencies: sxiv, imagemagick, bash, ffmpeg, mpc, jq, mpd
VERSION=1.2.9 VERSION=1.3.0
COVER=/tmp/kunst.jpg COVER=/tmp/kunst.jpg
MUSIC_DIR=~/Music/ MUSIC_DIR=~/Music/
SIZE=250x250 SIZE=250x250
@ -101,11 +101,16 @@ get_cover_online() {
return return
fi fi
# If the current playing song ends with .mp3 or something similar, remove
# it before searching for the album art because including the file extension
# reduces the chance of good results in the search query
QUERY=$(mpc current | sed 's/\.[^.]*$//')
# Try to get the album cover online from api.deezer.com # Try to get the album cover online from api.deezer.com
API_URL="https://api.deezer.com/search/autocomplete?q=$(mpc current)" && API_URL=${API_URL//' '/'%20'} API_URL="https://api.deezer.com/search/autocomplete?q=$QUERY" && API_URL=${API_URL//' '/'%20'}
# Extract the albumcover from the json returned # Extract the albumcover from the json returned
IMG_URL=$(curl -s "$API_URL" | jq -r '.playlists.data[0] | .picture_big') IMG_URL=$(curl -s "$API_URL" | jq -r '.tracks.data[0].album.cover_big')
if [ "$IMG_URL" = '' ] || [ "$IMG_URL" = 'null' ];then if [ "$IMG_URL" = '' ] || [ "$IMG_URL" = 'null' ];then
[ ! "$SILENT" ] && echo "error: cover not found online" [ ! "$SILENT" ] && echo "error: cover not found online"