Browse code

Create webradio.sh

Stefan Höhn authored on08/09/2016 21:45:43 • GitHub committed on08/09/2016 21:45:43
Showing1 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1,114 @@
1
+#! /bin/bash
2
+
3
+
4
+command -v mpg123 >/dev/null 2>&1 || { echo -e "$RED PMRP requires 'mpg123' but it's not installed! Install 'mpg123' to enjoy PMRP. $NC" >&2; exit 1; }
5
+
6
+
7
+
8
+DIALOG_CANCEL=1
9
+DIALOG_ESC=255
10
+DIALOG_OK=0
11
+HEIGHT=0
12
+WIDTH=0
13
+
14
+rm  fifo.txt
15
+touch fifo.txt
16
+rm mpg123.fifo
17
+mkfifo mpg123.fifo
18
+
19
+
20
+display_result() {
21
+  gdialog --title "$1" \
22
+    --no-collapse \
23
+    --stdout \
24
+    --msgbox "$result" 0 0 \
25
+  #--tailboxbg fifo.txt 0 0
26
+
27
+}
28
+
29
+while true; do
30
+  exec 3>&1
31
+  selection=$(gdialog \
32
+    --backtitle "SmaRPt Webradio" \
33
+    --title "Menu" \
34
+    --clear \
35
+    --cancel-label "Exit" \
36
+    --menu "Please select:" $HEIGHT $WIDTH 4 \
37
+    "1" "Radio1" \
38
+    "2" "Radio2" \
39
+    "3" "Radio3" \
40
+    2>&1 1>&3)
41
+  exit_status=$?
42
+  exec 3>&-
43
+  
44
+  case $exit_status in
45
+    $DIALOG_CANCEL)
46
+      clear
47
+   #   echo "Program terminated."
48
+      killall mpg123
49
+      exit
50
+      ;;
51
+      $DIALOG_OK)
52
+      
53
+   #   echo "Program terminated."
54
+      killall mpg123
55
+       ;;
56
+      
57
+      
58
+      
59
+    $DIALOG_ESC)
60
+      clear
61
+   #   echo "Program aborted." >&2
62
+      killall mpg123
63
+      exit 1
64
+      ;;
65
+  esac
66
+  case $selection in
67
+    0 )
68
+      clear
69
+  #    echo "Program terminated."
70
+      killall mpg123
71
+      ;;
72
+    1 )
73
+   mpg123 --control --utf8 --title --preload 1 --buffer 768 --smooth http://relay.181.fm:8042 > mpg123.fifo 2>&1> /dev/null &
74
+ 
75
+
76
+  
77
+  #exec -c "mpg123 -@ http://mp3-live.swr3.de/swr3_m.m3u 2>&1> /dev/null |grep --line-buffered "StreamTitle"> mpg123.fifo"l
78
+   cat mpg123.fifo >>fifo.txt &
79
+  
80
+  result=$(tail -n 30 fifo.txt|grep --line-buffered "StreamTitle"| sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g")
81
+    
82
+     display_result "Webradio" 
83
+
84
+      ;;
85
+    2 )
86
+      mpg123 --control --utf8 --title --preload 1 --buffer 768 --smooth http://relay.181.fm:8072 > mpg123.fifo 2>&1> /dev/null &
87
+ 
88
+
89
+  
90
+  #exec -c "mpg123 -@ http://mp3-live.swr3.de/swr3_m.m3u 2>&1> /dev/null |grep --line-buffered "StreamTitle"> mpg123.fifo"l
91
+   cat mpg123.fifo >>fifo.txt &
92
+  
93
+  result=$(tail -n 30 fifo.txt|grep --line-buffered "StreamTitle"| sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g")
94
+    
95
+     display_result "Webradio" 
96
+
97
+      ;;
98
+    3 )
99
+       mpg123 --control --utf8 --title --preload 1 --buffer 768 --smooth http://icyrelay.181.fm/181-blues_128k.mp3 > mpg123.fifo 2>&1> /dev/null &
100
+ 
101
+
102
+  
103
+  #exec -c "mpg123 -@ http://mp3-live.swr3.de/swr3_m.m3u 2>&1> /dev/null |grep --line-buffered "StreamTitle"> mpg123.fifo"l
104
+   cat mpg123.fifo >>fifo.txt &
105
+  
106
+  result=$(tail -n 30 fifo.txt|grep --line-buffered "StreamTitle"| sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g")
107
+    
108
+     display_result "Webradio" 
109
+
110
+      
111
+      ;;
112
+  esac
113
+done
114
+