# 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 "<xxxxx>${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" printf "$tab3${i%]}\n";; *SERVICE_ID*) vlcopts+=("program=${i//*= }");; *NETWORK_ID*) ;; *TRANSPORT_ID*) ;; *VIDEO_PID*) ;; *AUDIO_PID*) ;; *PID_06*) ;; *FREQUENCY*) freq=${i//*= };; *MODULATIONX*) vlcopts+=("dvb-modulation=${i//*= }");; *BANDWIDTH_HZ*) i=${i//*= } vlcopts+=("dvb-bandwidth=${i%000000}");; *INVERSION*) ;; *CODE_RATE_HP*) ;; *CODE_RATE_LP*) ;; *GUARD_INTERVAL*) vlcopts+=("dvb-guard=${i//*= }");; *TRANSMISSION_MODE*) i=${i//*= } vlcopts+=("dvb-transmission=${i}");; *HIERARCHY*) ;; *DELIVERY_SYSTEM*) case ${i: -1} in T) delsys='t';; 2) delsys='t2';; esac case $skip in 0) printf "$tab3dvb-$delsys://frequency=$freq\n" printf "$tab3\n" for j in ${!vlcopts[@]}; do printf "$tab4${vlcopts[$j]}\n" done printf "$tab4$idx\n" idx=$((idx += 1)) printf "$tab3\n" 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 }