# vim: ft=sh
ini_dvb_channels () {
local i y;
for y in $@; do
i=${y:0:2}
case ${y:2:3} in
T2) echo "T2 $(((i * 8) + 306))000000 8MHz AUTO NONE AUTO 32k 1/32 NONE";;
*) echo "T $(((i * 8) + 306))000000 8MHz AUTO NONE QAM64 8k 1/8 NONE";
esac
done
}
vlc_xspf_prolog () {
printf "\n"
printf "\n"
printf "\tDVB Playlist\n"
printf "\troro le ballot\n"
printf "\thttp://roro.le.ballot.free.fr/wiki/tnt/\n"
printf "\t\n"
}
vlc_xspf_epilog () {
printf "\t\n"
printf "\n"
}
run_lstv () {
local tab1="\t"
local i;
while read i; do
case $i in
\[.* | \['#'* | \[DATAS* | \[CANAL* | \[PLANETE* )
;;
.* | '#'* | DATAS* | CANAL* | PLANETE* )
;;
\[*)
i=${i#[}
printf "${i%]}\n";;
*:[0-9]*)
printf "${i%%:*}\n"
;;
*'DVB Playlist'*)
;;
*'
'*)
i=${i#*>}
printf "${i%<*}\n";;
*';'*)
i=${i#[}
printf "${i%]}\n";;
esac
done < <(cat $1);
}
trt_channels () {
local tab1="\t"
local tab2="\t\t"
local tab3="\t\t\t"
local tab4="\t\t\t\t"
local idx=1;
local i j skip;
while read i; do
case $i in
\[.* | \['#'* | \[DATAS* | \[CANAL* | \[PLANETE* )
skip=1;;
\[*)
skip=0
vlcopts=()
i=${i#[}
printf "$tab2\n";;
esac;;
esac
done < <(cat $1);
}
to_xspf_usage () {
echo "Usage: dvbv5_to_xspf [OPTION] [/path/to/channels.conf]"
echo "Convert channels.conf to channels.xspf in current directory"
echo ""
echo " -?, -h, --help, --usage Give this help list"
}
dvbv5_to_xspf () {
case $1 in
-h | -? | --usage | --help)
to_xspf_usage;;
*)
vlc_xspf_prolog | tee channels.xspf
trt_channels ${1:-channels.conf} | tee -a channels.xspf
vlc_xspf_epilog | tee -a channels.xspf;;
esac
}
lstv_usage () {
echo "Usage: lstv [OPTION] [/path/to/channels.conf]"
echo "Show channels from (.conf, .xspf or .zap} in current directory"
echo ""
echo " -?, -h, --help, --usage Give this help list"
}
lstv () {
case $1 in
-h | -? | --usage | --help)
lstv_usage;;
*)
run_lstv ${1:-channels.conf};;
esac
}