Browse code

Add files via upload

mpg123 und webradio-core als Funktion macht Code übersichtlicher.

Stefan Höhn authored on11/02/2018 12:37:01 • GitHub committed on11/02/2018 12:37:01
Showing1 changed files

... ...
@@ -1,10 +1,7 @@
1
-#! /bin/bash
2
-
1
+#!/bin/bash
3 2
 
4 3
 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 4
 
6
-
7
-
8 5
 DIALOG_CANCEL=1
9 6
 DIALOG_ESC=255
10 7
 DIALOG_OK=0
... ...
@@ -16,24 +13,32 @@ touch fifo.txt
16 13
 rm mpg123.fifo
17 14
 mkfifo mpg123.fifo
18 15
 
16
+radiostation()          {
17
+                      mpg123 --control --utf8 --title --preload 1 --buffer 768 --smooth $1 > mpg123.fifo 2>&1> /dev/null &
18
+                      cat mpg123.fifo >>fifo.txt &
19
+                      result=$(tail -n 30 fifo.txt|grep -a --line-buffered "StreamTitle"| sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g")
20
+                      display_result "Webradio" 
21
+                      
22
+                      }
23
+
24
+title=$( tail -n 1 fifo.txt|grep -a --line-buffered "StreamTitle"| sed -e 's/;.*//' -e 's/.*=//' -e "s/'//g")
19 25
 
20 26
 display_result() {
21 27
   gdialog --title "$1" \
22 28
     --no-collapse \
23 29
     --stdout \
24
-    --msgbox "$result" 0 0 \
25
-  #--tailboxbg fifo.txt 0 0
26
-
30
+    --infobox "$result" 0 0 \
31
+ 
27 32
 }
28 33
 
29 34
 while true; do
30 35
   exec 3>&1
31 36
   selection=$(gdialog \
32 37
     --backtitle "SmaRPt Webradio" \
33
-    --title "Menu" \
38
+    --title "Webradio" \
34 39
     --clear \
35 40
     --cancel-label "Exit" \
36
-    --menu "Please select:" $HEIGHT $WIDTH 4 \
41
+    --menu "Senderauswahl:" $HEIGHT $WIDTH 4 \
37 42
     "1" "Radio1" \
38 43
     "2" "Radio2" \
39 44
     "3" "Radio3" \
... ...
@@ -44,21 +49,15 @@ while true; do
44 49
   case $exit_status in
45 50
     $DIALOG_CANCEL)
46 51
       clear
47
-   #   echo "Program terminated."
48 52
       killall mpg123
49 53
       exit
50 54
       ;;
51 55
       $DIALOG_OK)
52
-      
53
-   #   echo "Program terminated."
54 56
       killall mpg123
55
-       ;;
56
-      
57
-      
58
-      
57
+      ;;
58
+           
59 59
     $DIALOG_ESC)
60 60
       clear
61
-   #   echo "Program aborted." >&2
62 61
       killall mpg123
63 62
       exit 1
64 63
       ;;
... ...
@@ -70,45 +69,14 @@ while true; do
70 69
       killall mpg123
71 70
       ;;
72 71
     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
-      ;;
72
+   radiostation http://relay.181.fm:8042
73
+   ;;
85 74
     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
-      ;;
75
+   radiostation http://relay.181.fm:8072 
76
+    ;;
98 77
     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
-      ;;
78
+    radiostation http://icyrelay.181.fm/181-blues_128k.mp3
79
+     ;;
112 80
   esac
113 81
 done
114 82