Update icecast2 FIP relay using HTTP/Json API http://zmpd.zered.net:8042/fip-metadata.mp3
python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fip_current.sh 847B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. host="ICECAST2_HOST:PORT"
  3. mount="/MOUNTPOINT"
  4. login="admin"
  5. passwd="hackme"
  6. fip_url="https://www.fip.fr/livemeta/7"
  7. fipmeta="/tmp/fip-meta"
  8. start=$(date "+%s")
  9. touch $fipmeta
  10. while [ 1 ]
  11. do
  12. q='.["steps"][.["levels"][0]["items"][.["levels"][0]["position"]]] |.["end"], .["title"]+" - "+.["authors"]+" ("+.["titreAlbum"]+")"'
  13. infos=$(curl -s $fip_url | jq -r "$q" )
  14. title=$(echo $infos |cut -d" " -f"2-"| sed 's/[^ ]\+/\L\u&/g')
  15. end=$(echo $infos |cut -d" " -f1)
  16. if [ "$(cat $fipmeta)" != "$title" ]
  17. then
  18. echo -n $title > $fipmeta
  19. echo $title
  20. curl -s -G "http://${login}:${passwd}@${host}/admin/metadata" \
  21. -d "mount=${mount}"
  22. -d "mode=updinfo"
  23. --data-urlencode "song=${title}" > /dev/null
  24. fi
  25. now=$(date "+%s")
  26. if [ "$now" -gt "$end" ]
  27. then
  28. sleep 1
  29. else
  30. delay=$(expr $end - $now)
  31. sleep $delay
  32. fi
  33. done