11#! /bin/bash
22# Bashtuner V2.0 by Born2Root
3- # Abspielen von Internetradios und Anzeigen eines PopUps, mit dem aktuellen Song
3+ # Play Internet Radio from Linux Command Line
44
5- # ====> Pfade definieren
6- pfadsender=" $HOME /Programme/bashtuner/sender.csv" ; # Pfad zur Senderliste
5+ # ====> Define Paths
76
8- # Ablageort der Logdatei und der Temporären Bilderablage (Ablum Pics)
7+ # Path to radio station list
8+ pfadsender=" $HOME /Programme/bashtuner/sender.csv" ;
9+
10+ # Path to Logfile and temporary picture save location (album covers)
911config_dir=~ /.bash_radio
1012fifo=$config_dir /fifo
1113image_file=$config_dir /image
1214log_file=$config_dir /log
1315
1416
15- # ====> Hauptprogramm
17+ # ====> Main Program
1618
1719if [ ! -d $config_dir ]; then
1820 mkdir $config_dir
@@ -29,23 +31,13 @@ playradio() {
2931auswahl=$( awk -F " " ' {print $1"\n"$2}' $pfadsender | zenity --list --hide-column=1 --column " Nummer" --column " Sender" --title=" Bashtuner" --ok-label=" Abspielen" --cancel-label=" Exit" --text=" Radiosender einschalten" --width=600 --height=300)
3032if [ $? = " 1" ] ; then exit 1 ; else
3133export play=$( cat $HOME /Programme/bashtuner/sender.csv | head -n" $auswahl " | tail -n1 | cut -d' ' -f3)
32- # # das ist meine Alte Lösung, wo der aktuelle Song nur im Terminal ausgegeben wird
33- # mplayer $play 2> /dev/null | awk -F\' '/StreamTitle/ {print $2}'
34- # echo 'message:' | zenity --notification --listen
35-
36-
37- # # das ist die neue Lösung
38- mplayer $play 2> /dev/null | stdbuf -o L grep --text ICY > $fifo &
39-
40- while read line < $fifo ; do
41- args=$( echo $line | sed -r " s/ICY Info: StreamTitle='([^-]*) - ([^']*)';StreamUrl='([^']*)';/\1;\2;\3/" )
42- saveIFS=$IFS ; IFS=" ;" ; set -- $args ; IFS=$saveIFS
43-
44- # Titel in Logfile schreiben
45- # echo $(date +%D) $1 - $2 >> $log_file
46- # Titel in Konsole ausgeben
47- echo $1 - $2
48- done
34+
35+ mplayer $play 2> /dev/null | awk -F\' ' /StreamTitle/ {print $2}'
36+
37+ # print current played song to terminal
38+ echo ' message:' | zenity --notification --listen
39+
40+
4941# wait
5042playradio
5143fi
0 commit comments