Help with adapting a script to Multiple Outputs

This script pulls out the matching "Group" Sports from my file to the output emby_sports.m3u. I have all the usual groups I.E. "News", "General Streams", "Movies".

Is it possible to adapt this script to "Pull all the groups" in one run and separate them into multiple files, or do I need a separate script for each one I need to pull?

This pulls the Group "Sports" Only....

#!/bin/sh    
while read -r LINE || [ -n "$LINE" ]; do
awk '/group-title="Sports"/{nr[NR]; nr[NR+1]}; NR in nr'
sed -i '1i #EXTM3U' emby_iptv_tmp.m3u
done < iptv_download.m3u
mv emby_iptv_tmp.m3u emby_sports.m3u
rm iptv_download.m3u

Here's an example of the output desired for all the lines that contain "Sports". I would like this to output all the groups, "General Streams", "Kids", "News" in one run.

Do I just repeat the awk statement and output over and over again as I have done with multiple scripts or is there some awk formatting that will do this on a one liner?

#EXTM3U
#EXTINF:-1 tvg-ID="" tvg-name="AU: Fox NRL League HD" tvg-logo="" group-title="Sports",AU: Fox NRL League HD
http://**************@gmail.com/**************/53441.m3u8
#EXTINF:-1 tvg-ID="Golf Channel CA" tvg-name="CA: Golf Channel UHD" tvg-logo="" group-title="Sports",CA: Golf Channel UHD
http://**************@gmail.com/**************/45062.m3u8
#EXTINF:-1 tvg-ID="Golf Channel CA" tvg-name="CA: Golf Channel" tvg-logo="" group-title="Sports",CA: Golf Channel
http://**************@gmail.com/**************/45369.m3u8
#EXTINF:-1 tvg-ID="HPItv" tvg-name="CA: HPItv (HORSE RACING)" tvg-logo="" group-title="Sports",CA: HPItv (HORSE RACING)
http://**************@gmail.com/**************/55732.m3u8

Solution 1:

I don’t know awk well enough, I’d just use grep and loop over the group names as follows:

for i in Sports News" Movies "General Streams"
do
  <input.m3u grep --no-group-separator -A1 'group-title="'"$i"\" >"$i.m3u"
  sed -i '1i #EXTM3U' "$i.m3u"
done

This saves the output in files called simply by the group name, e.g. Sports.m3u and General Streams.m3u.

The GNU parallel Install parallel equivalent to this loop is:

parallel '<input.m3u grep -A1 group-title=\"{}\" >{}.m3u;sed -i "1i #EXTM3U" {}.m3u' ::: Sports News Movies "General Streams"