-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiptv.sh
More file actions
41 lines (35 loc) · 785 Bytes
/
iptv.sh
File metadata and controls
41 lines (35 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
playlist=$1
user=$2
openNewStream () {
local playlist=$1
local chNum=$2
local url=$(cat $playlist | grep -A2 "#EXTINF:0, $chNum " | tail -1)
killall ffplay > /dev/null 2>&1
su - $user -c "export DISPLAY=:0 && ffplay $url -fs > /dev/null 2>&1 &"
}
sudo cec-ctl --tuner -m | while read a
do
if [[ "$a" = *number-* ]]
then
if [ $endOfInputHandle_PID ]
then
kill $endOfInputHandle_PID
else
digitCnt=0
digits=''
echo -n "\nCH: "
fi
digit=$(echo "$a" | grep -Po '\d\ ' | grep -Po '\d')
digits="$digits$digit"
digitCnt=$((digitCnt + 1))
echo -n $digit
if [ $digitCnt == 3 ]
then
openNewStream "$playlist" "$digits"
else
sleep 0.1
coproc endOfInputHandle (sleep 3 ; openNewStream "$playlist" "$digits" ;)
fi
fi
done