#!/bin/sh

# This is a very quick and dirty script to convert a adr.conf file to
# channels.conf entries.
#
# First try whether its output is usefull:
# > adr2vdr.sh adr.conf
#
# If this looks correct you can append it to your channels.conf like this:
# > adr2vdr.sh adr.conf >> /video/channels.conf

ADR_CONF=$1

CHANNELS_CONF=`/bin/sed -e "1,/^\[adr\]/d" \
                        -e "/^ *$/,$ d" \
                        -e "s/^  */ADR/" \
                        -e "s/, /:/" \
                        -e "s/.[0123456789][0123456789][0123456789], [vV]/:I1C12D0/" \
                        -e "s/.[0123456789][0123456789][0123456789], [hH]/:I1C12D12/" \
                        -e "s/, 22kHzOff, /M0B8T8G8Y0:T:0:0:/" \
                        -e "s/\.//" \
                        -e "s/, .*/0:0:0:1:0:0:/" \
                        $ADR_CONF`

NUM=0
for line in $CHANNELS_CONF
do
  echo $line$NUM
  NUM=`expr $NUM + 1`
done
