mirror of
https://github.com/anthonyaxenov/iptv.git
synced 2024-11-21 21:14:46 +00:00
New scripts to find channel in playlists
This commit is contained in:
parent
dd518af67c
commit
0e741bae8f
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,3 +1,7 @@
|
||||
/.idea
|
||||
/files
|
||||
a.m3u8
|
||||
/.vscode
|
||||
/downloaded
|
||||
*.m3u
|
||||
*.m3u.*
|
||||
*.m3u8
|
||||
*.m3u8.*
|
||||
|
@ -8,10 +8,11 @@
|
||||
# ./check-pls.sh local/pls.m3u
|
||||
# ./check-pls.sh https://example.com/pls.m3u
|
||||
#
|
||||
# Both *.m3u and *.m3u8 are supported.
|
||||
# 1st argument is playlist file name or URL.
|
||||
# If it is an URL it will be saved in /tmp and
|
||||
# checked as local file.
|
||||
#
|
||||
# If argument is link to playlist it will be
|
||||
# saved in /tmp and then check as local file.
|
||||
# Both *.m3u and *.m3u8 are supported.
|
||||
#
|
||||
#################################################
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
# ./download-all.sh
|
||||
#
|
||||
# All playlists from playlists.ini will be
|
||||
# downloaded in ./files directory
|
||||
# downloaded in ./downloaded directory
|
||||
#
|
||||
#################################################
|
||||
|
||||
mkdir files && \
|
||||
cd files && \
|
||||
mkdir -p downloaded && \
|
||||
cd downloaded && \
|
||||
grep -P "pls='(.*)'" ../playlists.ini | sed "s/^pls=//g" | sed "s/'//g" | tr -d '\r' | xargs wget
|
||||
|
20
tools/find-in-all.sh
Executable file
20
tools/find-in-all.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV channel finder (all playlists)
|
||||
#
|
||||
# Usage:
|
||||
# ./download-all.sh
|
||||
# ./find-in-all.sh disney
|
||||
#
|
||||
# 1st argument is channel name pattern.
|
||||
#
|
||||
#################################################
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
|
||||
[ ! -d ./downloaded ] && echo "Error: ./downloaded directory does not exist. Run $SCRIPT_DIR/tools/download-all.sh" && exit 1
|
||||
[ ! "$(ls -A ./downloaded)" ] && echo "Error: ./downloaded directory is empty. Run $SCRIPT_DIR/tools/download-all.sh" && exit 2
|
||||
for file in ./downloaded/*; do
|
||||
"$SCRIPT_DIR"/find-in-pls.sh "$1" "$file"
|
||||
done
|
78
tools/find-in-pls.sh
Executable file
78
tools/find-in-pls.sh
Executable file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV channel finder (one playlist)
|
||||
#
|
||||
# Usage:
|
||||
# ./find-in-pls.sh disney local/pls.m3u
|
||||
# ./find-in-pls.sh disney https://example.com/pls.m3u
|
||||
#
|
||||
# 1st argument is channel name pattern.
|
||||
#
|
||||
# 2nd argument is playlist file name or URL.
|
||||
# If it is an URL it will be saved in /tmp and
|
||||
# checked as local file.
|
||||
#
|
||||
# Both *.m3u and *.m3u8 are supported.
|
||||
#
|
||||
#################################################
|
||||
|
||||
awk '
|
||||
BEGIN {
|
||||
IGNORECASE=1
|
||||
channel = ARGV[1]
|
||||
playlist = ARGV[2]
|
||||
found_count = 0
|
||||
found_last = 0
|
||||
regex_ch = tolower(sprintf("^#EXTINF:.+,\s*(.*%s.*)", channel))
|
||||
regex_url = "^https?:\/\/.*$"
|
||||
|
||||
print "--------------------"
|
||||
print "\033[20m\033[97mPlaylist:\033[0m " playlist
|
||||
print "\033[20m\033[97mChannel to find:\033[0m " channel
|
||||
|
||||
if (playlist ~ /^http(s)?:\/\/.*/) {
|
||||
parts_count = split(playlist, parts, "/")
|
||||
file_name = parts[parts_count]
|
||||
code = system("wget " playlist " -qO /tmp/" file_name " > /dev/null")
|
||||
if (code == 0) {
|
||||
print "Saved in /tmp/" file_name
|
||||
} else {
|
||||
print "ERROR: cannot download playlist: " playlist
|
||||
exit 1
|
||||
}
|
||||
playlist = "/tmp/" file_name
|
||||
}
|
||||
|
||||
ARGV[1] = playlist
|
||||
delete ARGV[2]
|
||||
print "--------------------"
|
||||
}
|
||||
{
|
||||
sub("\r$", "", $0) # crlf -> lf
|
||||
if (tolower($0) ~ tolower(regex_ch)) {
|
||||
found_count++
|
||||
#print "\n\033[32m" FNR " FOUND:\033[0m\t" $0
|
||||
print "\n" $0
|
||||
found_last = FNR
|
||||
}
|
||||
if (found_last > 0) {
|
||||
if (tolower($0) ~ tolower(regex_url)) {
|
||||
#print "\t\t" $0
|
||||
print $0 "\n"
|
||||
found_last = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (found_count == 0) {
|
||||
print "\033[91mNothing found\033[0m"
|
||||
} else {
|
||||
print "--------------------"
|
||||
print "\033[20m\033[97mPlaylist:\033[0m " playlist
|
||||
print "\033[20m\033[97mChannel found:\033[0m " channel
|
||||
print "\033[20m\033[97mFound:\033[0m\033[32m " found_count "\033[0m"
|
||||
}
|
||||
}
|
||||
' $1 $2
|
Loading…
Reference in New Issue
Block a user