#!/bin/bash
# (C) 03/11/2012, Andrea Peluso (http://www.sya54m.eu)
# 0.1.1 (04/05/2013) - aggiunte nuove webradio
# 0.2.0 (07/04/2015) - aggiornati url webradio, aggiunto controllo player, cambiato dialogo di chiusura

if [ -x /usr/bin/mplayer ]; then
  PLAYER="mplayer"
elif [ -x /usr/bin/cvlc ]; then
  PLAYER="cvlc"
else
  kdialog --error "Nessun player trovato nel sistema" --caption aradio --icon kmix
  exit 1
fi
while [ true ]
do
  STAZIONE=$(kdialog --radiolist "Seleziona la stazione radio" a "Kiss Kiss" on b "m2o" off c "Radio 105 FM" off d "Radio 105 Hits" off e "Radio 105 Zoo" off f "Radio Deejay" off g "RDS" off h "RTL" off i "Virgin Radio" off --caption aradio --icon kmix)
  if [ "$STAZIONE" = "a" ]; then
    URL="http://wma08.fluidstream.net:4610/"
  elif [ "$STAZIONE" = "b" ]; then
    URL="http://radiom2o-lh.akamaihd.net/i/RadioM2o_Live_1@42518/master.m3u8"
  elif [ "$STAZIONE" = "c" ]; then
    URL="http://shoutcast.unitedradio.it:1101"
  elif [ "$STAZIONE" = "d" ]; then
    URL="http://shoutcast.unitedradio.it:1109"
  elif [ "$STAZIONE" = "e" ]; then
    URL="http://shoutcast.unitedradio.it:1413"
  elif [ "$STAZIONE" = "f" ]; then
    URL="http://mp3.kataweb.it:8000/RadioDeejay"
  elif [ "$STAZIONE" = "g" ]; then
    URL="http://www.rds.it:8000/stream"
  elif [ "$STAZIONE" = "h" ]; then
    URL="http://shoutcast.rtl.it:3010/"
  elif [ "$STAZIONE" = "i" ]; then
    URL="http://shoutcast.unitedradio.it:1301"
  else
    kdialog --passivepopup "Grazie per aver usato aradio.\n(C) 2012-2015, Andrea Peluso." --caption aradio --icon kmix
    exit 0
  fi
  $PLAYER $URL &
  kdialog --msgbox "Premi OK per uccidere $PLAYER e interrompere la riproduzione" --caption aradio --icon kmix
  killall $PLAYER
done
