Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tvheadend pids are BAD for .m3u file - do not use. Instead get .m3u file from official Inverto website.
#!/bin/sh
set -e # stop if any command returns a non-zero exit code
# #EXTM3U
# #EXTINF:-1 tvg-id="ARD.de" tvg-logo="ardhd" tvg-name="Das Erste HD" group-title="german",Das Erste HD
# http://192.168.0.3/?src=1&freq=11494&sr=22000&pol=h&msys=dvbs2&pids=0,5100,5101,5102,5103,5106
# #EXTINF:-1 tvg-id="ZDF.de" tvg-logo="zdfhd" tvg-name="ZDF HD" group-title="german",ZDF HD
# http://192.168.0.3/?src=1&freq=11362&sr=22000&pol=h&msys=dvbs2&pids=0,6100,6110,6120,6121,6123,6122
# #EXTINF:-1 tvg-id="RTL.de" tvg-logo="rtl" tvg-name="RTL Television" group-title="german",RTL Television
# http://192.168.0.3/?src=1&freq=12188&sr=27500&pol=h&msys=dvbs&pids=0,44,163,104,106
# #EXTINF:-1 tvg-id="RTL2.de" tvg-logo="rtl2" tvg-name="RTL 2" group-title="german",RTL 2
# http://192.168.0.3/?src=1&freq=12188&sr=27500&pol=h&msys=dvbs&pids=0,46,166,128
if [ ! "$(command -v jq)" ]; then
echo "error: cannot find the program - \"jq\" on your \$PATH. jq is needed to parse json files."
echo "You must install jq before using this script."
exit 1
fi
__cat_help ()
{
cat <<- "EOF"
tvheadend-make-xbmc-iptv-m3ulist:
Convert tvheadend configuration folder into a .m3u playlist \for xbmc iptv PVR addon.
Usage:
$ tvheadend-make-xbmc-iptv-m3ulist [args]
$ cd /usr/local/etc/tvheadend/input/dvb/networks/2c0f0a2982f74e4e9eefc5eb72070dce/muxes
$ tvheadend-make-xbmc-iptv-m3ulist -i 192.168.1.100 -d "$PWD" -o "~/astra-28.2e.m3u"
Arguments:
-i,--satip - Static ip address of your local sat>ip box. Example: '192.168.1.100'
Only known to work \for Inverto IDL 400 / Telestar Digibit R1 / GSS.Box
-d,--muxes-dir - The tvheadend 'muxes' DIR. There is one in each dvb network. example:
/usr/local/etc/tvheadend/input/dvb/networks/2c0f0a2982f74e4e9eefc5eb72070dce/muxes
-o,--m3ulist - The output .m3u playlist filename. Example: 'astra-28.2e.m3u'
-h,--help - Display this message and exit.
EOF
}
__cat__next_steps ()
{
cat <<- "EOF"
All done! m3ulist written to: \"$m3ulist\"
You need to do 2 things with this file:
1) Load it up into the Firmware Web interface of your SAT>IP box.
Example, open http://$satip in a browser, click on 'M3U List' tab
and Click 'Browse' --> Select '$m3ulist'
and Click 'Send' to upload the .m3u playlist file.
2) Import the .m3u playlist file into the xbmc settings of the Simple-XMLTV addon
If you are updating an existing file, then disable->enable the addon to refresh the channel list.
EOF
}
__parse_args ()
{
if [ "$#" -gt "0" ]; then
for arg in "$@"; do
case "$arg" in
-i|--satip) next_is_satip="1" ;;
-d|--muxes-dir) next_is_muxes_dir="1" ;;
-o|--m3ulist) next_is_m3ulist="1" ;;
-h|--help) __cat_help; exit 1 ;;
*)
if [ "$next_is_satip" ]; then
satip="$arg"
unset next_is_satip
elif [ "$next_is_muxes_dir" ]; then
muxes_dir="$(eval "echo $arg")"
unset next_is_muxes_dir
elif [ "$next_is_m3ulist" ]; then
m3ulist="$(eval "echo $arg")"
unset next_is_m3ulist
else
echo "error (1): unrecognised command line parameter - \"$arg\". \`$0 --help\` for more info."
exit 1
fi
;;
esac
done
else
__cat_help; return 1;
fi
if [ ! -d "$muxes_dir" ]; then
echo "error: Bad muxes_dir - \"$muxes_dir\" is not a directory"
exit 1
fi
if [ -e "$m3ulist" ]; then
echo "error: m3ulist - \"$m3ulist\" already exists."
exit 1
fi
}
__make_m3ulist ()
{
echo "#EXTM3U" > "$m3ulist"
cd "$muxes_dir"
for mux in *; do
cd "$muxes_dir"
# from ${mux}/config
IFS="
"
set $(jq -r '.enabled,.frequency,.symbolrate,.cridauth' ${mux}/config)
unset IFS
for param in enabled frequency symbol_rate group_title; do
eval "unset $param ; $param=\"$1\""
shift
done
if [ "$enabled" = "true" ]; then
set $(jq -r '.polarisation,.delsys' ${mux}/config | tr '[:upper:]' '[:lower:]')
for param in polarisation msys; do
eval "unset $param ; $param=\"$1\""
shift
done
# symbol_rate="$(echo "$symbol_rate / 1000" | bc)"
#symbol_rate="${symbol_rate%000}"
symbol_rate="$(echo "($symbol_rate + 500) / 1000" | bc)"
frequency="$(echo "($frequency + 500) / 1000" | bc)"
#frequency=11494
#symbol_rate=27500
#polarisation=h
#polarisation=v
#msys=dvbs
#msys=dvbs2
#group_title=
if [ -d "${muxes_dir}/${mux}/services" ]; then
cd "${muxes_dir}/${mux}/services"
for service in *; do
# from ${mux}/services/${service}
#channel_name="Sky Sports 5 HD"
#pids=0,46,166,128
IFS="
"
set $(jq -r '.enabled,.svcname,.stream[].pid' ${service})
unset IFS
for param in enabled channel_name; do
eval "unset $param ; $param=\"$1\""
shift
done
if [ "$enabled" = "true" ] && [ "$channel_name" ]; then
pids="$(echo "$@" | tr ' ' ',')"
if [ "$pids" ]; then
# m3u entries format / examples:
# http://kodi.wiki/view/Add-on:IPTV_Simple_Client
# https://github.com/afedchin/xbmc-addon-iptvsimple/wiki/IPTV-Simple-Home
# tvg-id="Channel Name" if defined in channels
# else use tvg-name as service name or via-versa
# group-title="Tag name"
cat >> "$m3ulist" <<- EOF
#EXTINF:-1 tvg-logo-id="" tvg-logo="" tvg-name="${channel_name}" group-title="${group_title}",${channel_name}
http://${satip}/?src=1&freq=${frequency}&sr=${symbol_rate}&pol=${polarisation}&msys=${msys}&pids=0,${pids}
EOF
fi
fi
done
fi
fi
done
__cat_next_steps;
exit 0
}
__main ()
{
__parse_args "$@";
__make_m3ulist;
}
__main "$@";
@amenk

This comment has been minimized.

Copy link

@amenk amenk commented Apr 30, 2017

I try to generate a full channel List (also with SD channels) for my Megasat SAT IP server II and the MAG 254 set top box.
The M3U from www.satip.info/resources?tid=All works but is not complete.

So I scanned with tvheadend and used your script.

M3U from satip.info (works)
http://192.168.178.104/?src=1&freq=11494&pol=h&ro=0.35&msys=dvbs2&mtype=8psk&plts=on&sr=22000&fec=23&pids=0,17,18,5100,5101,5102,5104

M3U from this script (does not work)
http://192.168.178.104/?src=1&freq=11494&sr=22000&pol=h&msys=dvbs2&pids=0,5101,5102,5103,5104,5105,5106

Any clue what's going on here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment