Перекладка и апгрейд проекта под расширение
This commit is contained in:
77
src/scripts/check-pls.sh
Executable file
77
src/scripts/check-pls.sh
Executable file
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV Playlist check tool
|
||||
#
|
||||
# Usage:
|
||||
# ./check-pls.sh local/pls.m3u
|
||||
# ./check-pls.sh https://example.com/pls.m3u
|
||||
#
|
||||
# 1st 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.
|
||||
#
|
||||
# Anthony Axenov (c) 2022
|
||||
# The MIT License:
|
||||
# https://github.com/anthonyaxenov/iptv/blob/master/LICENSE
|
||||
#
|
||||
#################################################
|
||||
|
||||
awk '
|
||||
BEGIN {
|
||||
total_count=0
|
||||
success_count=0
|
||||
fail_count=0
|
||||
print "\033[20m\033[97mPlaylist:\033[0m " ARGV[1]
|
||||
if (ARGV[1] ~ /^http(s)?:\/\/.*/) {
|
||||
parts_count = split(ARGV[1], parts, "/")
|
||||
file_name = parts[parts_count]
|
||||
code = system("wget " ARGV[1] " -qO /tmp/" file_name " > /dev/null")
|
||||
if (code == 0) {
|
||||
print "Saved in /tmp/" file_name
|
||||
} else {
|
||||
print "ERROR: cannot download playlist: " ARGV[1]
|
||||
exit 1
|
||||
}
|
||||
ARGV[1] = "/tmp/" file_name
|
||||
}
|
||||
print ""
|
||||
print "\033[20m\033[97mNote 1:\033[0m operation may take some time, press CTRL+C to stop."
|
||||
print "\033[20m\033[97mNote 2:\033[0m results may be inaccurate, you should use proper IPTV software to re-check."
|
||||
print "\033[20m\033[97mNote 3:\033[0m error codes listed here - https://everything.curl.dev/usingcurl/returns"
|
||||
print "--------------------"
|
||||
}
|
||||
{
|
||||
sub("\r$", "", $0) # crlf -> lf
|
||||
if ($0 ~ /^#EXTINF:.+,/) {
|
||||
total_count++
|
||||
channel_name = substr($0, index($0, ",") + 1, length($0))
|
||||
print "\n[" total_count "] " channel_name
|
||||
}
|
||||
if ($0 ~ /^http(s)?:\/\/.*/) {
|
||||
url = sprintf("%c%s%c", 34, $0, 34) # 34 is "
|
||||
cmd = "curl -fs --max-time 5 -w \"%{http_code}\" --max-filesize 5000 -o /dev/null " url
|
||||
cmd | getline http_code
|
||||
code = close(cmd)
|
||||
if (http_code == "000") {
|
||||
http_code = "-"
|
||||
}
|
||||
if (code == 0 || code == 63) {
|
||||
print "\033[32mOK:\033[0m " url
|
||||
success_count++
|
||||
} else {
|
||||
print "\033[91mERROR\033[0m " code " (" http_code "): " url
|
||||
fail_count++
|
||||
}
|
||||
}
|
||||
}
|
||||
END {
|
||||
print "--------------------"
|
||||
print "\033[20m\033[97mPlaylist:\033[0m " ARGV[1]
|
||||
print "- Success:\t\033[32m" success_count "\033[0m/" total_count
|
||||
print "- Failed: \t\033[91m" fail_count "\033[0m/" total_count
|
||||
}
|
||||
' $1
|
||||
31
src/scripts/download-all.sh
Executable file
31
src/scripts/download-all.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV Playlist download tool
|
||||
#
|
||||
# Usage:
|
||||
# ./download-all.sh
|
||||
#
|
||||
# All playlists from playlists.ini will be
|
||||
# downloaded in ./downloaded directory
|
||||
#
|
||||
# Anthony Axenov (c) 2022
|
||||
# The MIT License:
|
||||
# https://github.com/anthonyaxenov/iptv/blob/master/LICENSE
|
||||
#
|
||||
#################################################
|
||||
|
||||
TOOLS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
|
||||
DL_DIR="$TOOLS_DIR/downloaded"
|
||||
INI_FILE="$(dirname "$TOOLS_DIR")/../../playlists.ini"
|
||||
|
||||
rm -rf "$DL_DIR" && \
|
||||
mkdir -p "$DL_DIR" && \
|
||||
cd "$DL_DIR" && \
|
||||
cat "$INI_FILE" \
|
||||
| grep -P "pls\s*=\s*'(.*)'" \
|
||||
| sed "s#^pls\s*=\s*##g" \
|
||||
| sed "s#'##g" \
|
||||
| tr -d '\r' \
|
||||
| xargs wget
|
||||
25
src/scripts/find-in-all.sh
Executable file
25
src/scripts/find-in-all.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV channel finder (all playlists)
|
||||
#
|
||||
# Usage:
|
||||
# ./download-all.sh
|
||||
# ./find-in-all.sh "(disney|atv)"
|
||||
#
|
||||
# 1st argument is channel name pattern.
|
||||
#
|
||||
# Anthony Axenov (c) 2022
|
||||
# The MIT License:
|
||||
# https://github.com/anthonyaxenov/iptv/blob/master/LICENSE
|
||||
#
|
||||
#################################################
|
||||
|
||||
TOOLS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
|
||||
DL_DIR="$TOOLS_DIR/downloaded"
|
||||
[ ! -d "$DL_DIR" ] && echo "Error: 'tools/downloaded' directory does not exist. Run tools/download-all.sh" && exit 1
|
||||
[ ! "$(ls -A "$DL_DIR")" ] && echo "Error: 'tools/downloaded' directory is empty. Run tools/download-all.sh" && exit 2
|
||||
for file in $TOOLS_DIR/downloaded/*; do
|
||||
$TOOLS_DIR/find-in-pls.sh "$1" "$file"
|
||||
done
|
||||
84
src/scripts/find-in-pls.sh
Executable file
84
src/scripts/find-in-pls.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/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.
|
||||
#
|
||||
# Anthony Axenov (c) 2022
|
||||
# The MIT License:
|
||||
# https://github.com/anthonyaxenov/iptv/blob/master/LICENSE
|
||||
#
|
||||
#################################################
|
||||
|
||||
channel="$1"
|
||||
playlist="$2"
|
||||
playlist_url="$playlist"
|
||||
regex_ch="^#extinf:\s*-?[01]\s*.*,(.*${channel,,}.*)"
|
||||
regex_url="^https?:\/\/.*$"
|
||||
|
||||
is_downloaded=0
|
||||
download_dir="/tmp/$(date '+%s%N')"
|
||||
|
||||
found_count=0
|
||||
found_last=0
|
||||
line_count=1
|
||||
|
||||
if [[ "$playlist" =~ $regex_url ]]; then
|
||||
mkdir -p "$download_dir"
|
||||
cd "$download_dir"
|
||||
wget "$playlist" -q > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
is_downloaded=1
|
||||
playlist="$download_dir/$(ls -1 "$download_dir")"
|
||||
cd - > /dev/null
|
||||
else
|
||||
echo "ERROR: cannot download playlist: $playlist"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "--------------------"
|
||||
echo -e "\033[20m\033[97mChannel:\033[0m $channel"
|
||||
echo -e "\033[20m\033[97mPlaylist:\033[0m $playlist_url"
|
||||
echo -e "\033[20m\033[97mRegex:\033[0m $regex_ch"
|
||||
echo "--------------------"
|
||||
|
||||
while read line; do
|
||||
if [[ "${line,,}" =~ $regex_ch ]]; then
|
||||
echo -e "\n\033[32m$line_count FOUND:\033[0m\t$line"
|
||||
((found_count += 1))
|
||||
found_last=$found_count
|
||||
fi
|
||||
if [ $found_last -gt 0 ]; then
|
||||
if [[ "${line,,}" =~ $regex_url ]]; then
|
||||
echo -e "\t\t$line"
|
||||
found_last=0
|
||||
fi
|
||||
fi
|
||||
((line_count += 1))
|
||||
done < $playlist
|
||||
|
||||
if [ $found_count -eq 0 ]; then
|
||||
echo -e "\033[91mNothing found\033[0m"
|
||||
else
|
||||
echo "--------------------"
|
||||
echo -e "\033[20m\033[97mChannel:\033[0m $channel"
|
||||
echo -e "\033[20m\033[97mPlaylist:\033[0m $playlist_url"
|
||||
echo -e "\033[20m\033[97mFound:\033[0m\033[32m $found_count\033[0m"
|
||||
fi
|
||||
|
||||
if [ $is_downloaded -eq 1 ]; then
|
||||
rm -rf "$download_dir"
|
||||
fi
|
||||
55
src/scripts/make-pls.sh
Executable file
55
src/scripts/make-pls.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################
|
||||
#
|
||||
# IPTV channel maker (all playlists)
|
||||
#
|
||||
# Usage:
|
||||
# ./download-all.sh
|
||||
# ./make-pls.sh "disney"
|
||||
#
|
||||
# 1st argument is channel name pattern.
|
||||
#
|
||||
# To save output in file use redirection:
|
||||
# ./make-pls.sh "disney" > disney.m3u8
|
||||
#
|
||||
# Anthony Axenov (c) 2022
|
||||
# The MIT License:
|
||||
# https://github.com/anthonyaxenov/iptv/blob/master/LICENSE
|
||||
#
|
||||
#################################################
|
||||
|
||||
TOOLS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
|
||||
DL_DIR="$TOOLS_DIR/downloaded"
|
||||
[ ! -d "$DL_DIR" ] && echo "Error: 'tools/downloaded' directory does not exist. Run tools/download-all.sh" && exit 1
|
||||
[ ! "$(ls -A "$DL_DIR")" ] && echo "Error: 'tools/downloaded' directory is empty. Run tools/download-all.sh" && exit 2
|
||||
|
||||
channel="$1"
|
||||
playlist="$2"
|
||||
|
||||
regex_ch="^#extinf:\s*-?[01]\s*.*,(.*${channel,,}.*)"
|
||||
regex_url="^https?:\/\/.*$"
|
||||
|
||||
found_count=0
|
||||
found_last=0
|
||||
|
||||
echo "#EXTM3U"
|
||||
echo "# Autogenerated at `date +%d.%m.%Y`"
|
||||
echo "# https://github.com/anthonyaxenov/iptv"
|
||||
echo
|
||||
|
||||
for file in ./downloaded/*; do
|
||||
while read line; do
|
||||
if [[ "${line,,}" =~ $regex_ch ]]; then
|
||||
echo -e "$line"
|
||||
((found_count += 1))
|
||||
found_last=$found_count
|
||||
fi
|
||||
if [ $found_last -gt 0 ]; then
|
||||
if [[ "${line,,}" =~ $regex_url ]]; then
|
||||
echo -e "$line\n"
|
||||
found_last=0
|
||||
fi
|
||||
fi
|
||||
done < $file
|
||||
done
|
||||
Reference in New Issue
Block a user