Implementation
This commit is contained in:
parent
58674ae93b
commit
8ee6f31ca8
2 changed files with 97 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
|||
## IPTV-Checker (Changelog)
|
||||
|
||||
* v1.0 - Implemented automatic detection of xml iptv files
|
||||
* v1.0 - Bug fix & implementation , changed how iptv-check filters the m3u file lists and from now will autoremove repeated urls on lists to scan
|
||||
* v1.0 - Bug fix , waiting for data was change from 2s to 4s because servers may take sometime to start sending data
|
||||
* v1.0 - First Release
|
||||
104
iptv-check
104
iptv-check
|
|
@ -68,12 +68,31 @@ exit 1
|
|||
fi
|
||||
}
|
||||
|
||||
function writefile2() {
|
||||
if [[ -f "$wfile" ]]
|
||||
then
|
||||
gturlline=$(grep -n "\<$chkf\>"<$path/temp/2 | tr ":" "\n" | sed -n 1p)
|
||||
stdata=$(sed -n "$gturlline p"< $path/temp/2 | awk '{$1=""; print $0}')
|
||||
echo "#EXTINF:-1 ,$stdata" >> "$wfile"
|
||||
echo "$chkf" >> "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
else
|
||||
echo "#EXTM3U" > "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
gturlline=$(grep -n "\<$chkf\>"<$path/temp/2 | tr ":" "\n" | sed -n 1p)
|
||||
stdata=$(sed -n "$gturlline p"< $path/temp/2 | awk '{$1=""; print $0}')
|
||||
echo "#EXTINF:-1 ,$stdata" >> "$wfile"
|
||||
echo "$chkf" >> "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
fi
|
||||
}
|
||||
|
||||
function writefile() {
|
||||
if [[ -f "$wfile" ]]
|
||||
then
|
||||
gturlline=$(grep -n "\<$chkf\>"<$path/temp/1 | tr ":" "\n" | sed -n 1p)
|
||||
gturlline=$((gturlline-1))
|
||||
stdata=$(sed -n "${gturlline}p"< $path/temp/1)
|
||||
defline=$((gturlline-1))
|
||||
stdata=$(sed -n "$defline p"< $path/temp/1)
|
||||
echo "$stdata" >> "$wfile"
|
||||
echo "$chkf" >> "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
|
|
@ -81,13 +100,78 @@ else
|
|||
echo "#EXTM3U" > "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
gturlline=$(grep -n "\<$chkf\>"<$path/temp/1 | tr ":" "\n" | sed -n 1p)
|
||||
gturlline=$((gturlline-1))
|
||||
stdata=$(sed -n "${gturlline}p"< $path/temp/1)
|
||||
defline=$((gturlline-1))
|
||||
stdata=$(sed -n "$defline p"< $path/temp/1)
|
||||
echo "$stdata" >> "$wfile"
|
||||
echo "$chkf" >> "$wfile"
|
||||
echo "" >> "$wfile"
|
||||
fi
|
||||
}
|
||||
|
||||
function xmlproc() {
|
||||
grep -F "http" <$path/temp/1 | sed 's/<link>//g' | sed 's/^.*http/http/' | sed 's/&.*|//' | sed -e 's/\(.ts\).*\(=\)/\1\2/' | sed 's/=/ /g' | sed "s~</link>~ ~g" > $path/temp/2
|
||||
srvnmb=$(wc -l "$path/temp/2" | awk '{print$1}')
|
||||
rm -rf "$path/temp/stream" >/dev/null 2>&1
|
||||
rm -rf "$path/temp/pid.tmp" >/dev/null 2>&1
|
||||
echo ""
|
||||
echo -e "$red""Press CTRL+C To Stop or Abort IPTV list check"
|
||||
echo ""
|
||||
for i in $(seq "$srvnmb")
|
||||
do
|
||||
chkf=$(sed -n "${i}p" < "$path/temp/2" | awk {'print$1}')
|
||||
chkurl=$(echo "$chkf" | head -c 4)
|
||||
case "$chkurl" in
|
||||
http|rtmp|HTTP)
|
||||
wget -q "$chkf" -O "$path/temp/stream" & echo $! > "$path/temp/pid.tmp"
|
||||
pid=$(sed -n 1p < "$path/temp/pid.tmp")
|
||||
sleep 4
|
||||
rpid=$(ps -p "$pid" -o pid= | awk '{print$1}')
|
||||
if [[ "$rpid" == "$pid" ]]
|
||||
then
|
||||
kill $pid
|
||||
fi
|
||||
if [[ ! -f "$path/temp/stream" ]]
|
||||
then
|
||||
echo -e "$yellow" "Error reading captured file"
|
||||
else
|
||||
stsz=$(wc -c "$path/temp/stream" | awk '{print$1}')
|
||||
if [[ "$stsz" -le "100" ]]
|
||||
then
|
||||
echo -e "$green" "Link:$yellow $i$green of :$yellow$srvnmb$green is$red OFF"
|
||||
else
|
||||
echo -e "$green" "Link:$yellow $i$green of :$yellow$srvnmb$green is$green ON"
|
||||
writefile2
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
rm -rf "$path/temp/stream" >/dev/null 2>&1
|
||||
rm -rf "$path/temp/pid.tmp" >/dev/null 2>&1
|
||||
warn
|
||||
done
|
||||
if [[ "$exts" == "0" ]]
|
||||
then
|
||||
if [[ -f "$wfile" ]]
|
||||
then
|
||||
echo ""
|
||||
echo -e "$green" "Job Finished"
|
||||
echo ""
|
||||
echo -e "$yellow" "You can find your new iptv list in :"
|
||||
echo -e "$orange" "$wfile"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
echo -e "$green" "Job Finished"
|
||||
echo ""
|
||||
echo -e "$yellow" "Your iptv list was update in :"
|
||||
echo -e "$orange" "$wfile"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function teststream() {
|
||||
wrn="0"
|
||||
if [[ -f "$wfile" ]]
|
||||
|
|
@ -96,7 +180,11 @@ exts="1"
|
|||
else
|
||||
exts="0"
|
||||
fi
|
||||
|
||||
ckf=$(grep "<item>" <$path/temp/1)
|
||||
if [[ ! -z "$ckf" ]]
|
||||
then
|
||||
xmlproc
|
||||
fi
|
||||
glnk=$(grep -F "http" < "$path/temp/1" | sed '/EXTINF/d' | sed '/EXTM3U/d' | awk '!a[$0]++' | sed '/^$/d')
|
||||
echo "$glnk" | tr " " "\n" > "$path/temp/2"
|
||||
srvnmb=$(wc -l "$path/temp/2" | awk '{print$1}')
|
||||
|
|
@ -163,14 +251,14 @@ fi
|
|||
|
||||
|
||||
function remotef() {
|
||||
wget "$file" -O "$path/temp/1" >/dev/null 2>&1
|
||||
wget "{$file}" -O "$path/temp/1" >/dev/null 2>&1
|
||||
flsz=$(wc -c "$path/temp/1" | awk '{print$1}')
|
||||
if [[ "$flsz" -le "10" ]]
|
||||
then
|
||||
echo -e "$yellow" "The remote link is down or the file size of it"
|
||||
echo -e "$yellow" " is too small to be an m3u iptv list file"
|
||||
echo ""
|
||||
exit 1
|
||||
exit 0
|
||||
fi
|
||||
teststream
|
||||
}
|
||||
|
|
@ -188,7 +276,7 @@ flsz=$(wc -c "$path/temp/1" | awk '{print$1}')
|
|||
if [[ "$flsz" -le "10" ]]
|
||||
then
|
||||
echo -e "$yellow" "The file you specified is too small to be an m3u iptv file"
|
||||
exit 1
|
||||
exit 0
|
||||
fi
|
||||
teststream
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue