Initial commit
This commit is contained in:
55
make-pls.sh
Executable file
55
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://git.axenov.dev/IPTV/tools/src/branch/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: '$DL_DIR' directory does not exist. Run ./download-all.sh" && exit 1
|
||||
[ ! "$(ls -A "$DL_DIR")" ] && echo "Error: '$DL_DIR' directory is empty. Run ./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://git.axenov.dev/IPTV/tools"
|
||||
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