But the save_channels function tries to read the url first, resulting in channels not pairing with their corresponding urls. When trying to reach ABC news, I get Bloomberg for example.
Below fixes this issue for me:
save_channels() {
m3u_url=$(cat "$m3u_url_file")
printf "\nLoading channels... "
curl -s "$m3u_url" | grep EXTINF: -A 2 > $tmp_playlist
printf "Done!\n"
printf "Parsing channels... "
channels=()
url=""
while IFS= read -r line; do
if [[ "$line" =~ tvg-name=\"([^\"]+)\" || "$line" =~ tvg-id=\"([^\"]+)\" ]]; then
name="${BASH_REMATCH[1]}"
url=""
elif [[ "$line" == http* ]]; then
url="$line"
channels+=("$name [CH:${#channels[@]}] url:$url")
fi
done < "$tmp_playlist"
printf "Done!\n"
printf "%s\n" "${channels[@]}" > $channels_file
}
Hello,
The m3u8 file I used, https://raw.githubusercontent.com/Free-TV/IPTV/master/playlist.m3u8, has the name of the channel come before the url, like so:
But the save_channels function tries to read the url first, resulting in channels not pairing with their corresponding urls. When trying to reach ABC news, I get Bloomberg for example.
Below fixes this issue for me: