Break out saving channels into a function

This commit is contained in:
Shahin Agha-Ghassem 2023-03-19 21:51:43 +01:00
parent bbed9f89f2
commit c608750c3a

6
iptv
View File

@ -16,7 +16,7 @@ if [ -z "$m3u" ] && [ ! -s "$channels_file" ]; then
exit 1 exit 1
fi fi
if [ ! -z "$m3u" ]; then save_channels() {
printf "\nLoading channels... " printf "\nLoading channels... "
curl -s $m3u | grep EXTINF: -A 2 > $tmp_playlist curl -s $m3u | grep EXTINF: -A 2 > $tmp_playlist
printf "Done!\n" printf "Done!\n"
@ -46,6 +46,10 @@ if [ ! -z "$m3u" ]; then
printf "Done!\n" printf "Done!\n"
printf "%s\n" "${channels[@]}" > $channels_file printf "%s\n" "${channels[@]}" > $channels_file
}
if [ ! -z "$m3u" ]; then
save_channels
echo "Playlist saved. Now run iptv again without a M3U URL." echo "Playlist saved. Now run iptv again without a M3U URL."
exit exit