#!/bin/sh host="ICECAST2_HOST:PORT" mount="/MOUNTPOINT" login="admin" passwd="hackme" fip_url="https://www.fip.fr/livemeta/7" fipmeta="/tmp/fip-meta" start=$(date "+%s") touch $fipmeta while [ 1 ] do q='.["steps"][.["levels"][0]["items"][.["levels"][0]["position"]]] |.["end"], .["title"]+" - "+.["authors"]+" ("+.["titreAlbum"]+")"' infos=$(curl -s $fip_url | jq -r "$q" ) title=$(echo $infos |cut -d" " -f"2-"| sed 's/[^ ]\+/\L\u&/g') end=$(echo $infos |cut -d" " -f1) if [ "$(cat $fipmeta)" != "$title" ] then echo -n $title > $fipmeta echo $title curl -s -G "http://${login}:${passwd}@${host}/admin/metadata" \ -d "mount=${mount}" -d "mode=updinfo" --data-urlencode "song=${title}" > /dev/null fi now=$(date "+%s") if [ "$now" -gt "$end" ] then sleep 1 else delay=$(expr $end - $now) sleep $delay fi done