dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

tag-song.sh (891B)


      1 #!/usr/bin/env bash
      2 
      3 genre="$1"
      4 appleMusicID="$2"
      5 shift
      6 shift
      7 
      8 if [ "$appleMusicID" = "file.jpg" ]; then
      9 	cp file.jpg "$XDG_CACHE_HOME/art.jpg"
     10 	art="file.jpg"
     11 else
     12 	searchLink="https://itunes.apple.com/lookup?id=${appleMusicID}&entity=song"
     13 	json="$(curl "$searchLink")"
     14 	if [[ "$(echo "$json" | jq .results[0].collectionName)" == "null" ]]; then
     15 		echo null
     16 		searchLink="https://itunes.apple.com/lookup?id=${appleMusicID}&entity=album"
     17 		json="$(curl "$searchLink")"
     18 	fi
     19 
     20 	art="$(echo "$json" | jq -r .results[0].artworkUrl100 | sed 's/100x100bb/1500x1500/g')"
     21 	if [ "$art" = "null" ]; then
     22 		art="$(echo "$json" | jq -r .results[1].artworkUrl100 | sed 's/100x100bb/1500x1500/g')"
     23 	fi
     24 fi
     25 
     26 echo $art
     27 for arg; do
     28 	echo "$arg"
     29 	"$HOME/.local/share/regexghost/.venv/bin/python3" "${XDG_DATA_HOME}/regexghost/terminal/tag-music.py" "$arg" "$genre" "$art"
     30 done
     31 
     32 rm -f "$XDG_CACHE_HOME/art.jpg"