Public domain
#!/usr/bin/bash
#
# dvbchopper -- simple frontend for Digital TV viewing tools (DVB)
#
# dvbchopper uses :
#
# DVB Driver ( http://www.linuxtv.org/ )
# channels.conf made by szap ( from http://www.linuxtv.org/ )
# MPlayer ( from http://www.mplayerhq.hu/ )
# dvbstream ( from http://sourceforge.net/projects/dvbtools/ )
# dialog ( from http://hightek.org/dialog/ )
#
# Copyright (C) 2007 Pejman Moghadam ( pejman@AltCtrlDel.com )
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#DIR=$(pwd)
DIR="/usr/local/dvb"
dialog --title "Welcome" \
--msgbox "\n Welcome to DVB-Chopper Suit !\n Written by : Pejman Moghadam" 8 0
dialog --title "channels.conf" \
--inputbox "Whereis channels.conf:" 0 0 $DIR 2> /tmp/dvbview.tst
if [ $? = 1 ]; then
rm /tmp/dvbview.tst
clear
echo "Cancelled !!!"
exit 0
fi
CHANNELS=$(cat /tmp/dvbview.tst)"/channels.conf"
if [ ! -f $CHANNELS ]; then
dialog --title "Not Found" \
--msgbox "\n $CHANNELS not found !!!" 7 70
rm /tmp/dvbview.tst
clear
exit 0
fi
LIST=$(sed -e 's,\:.*,:,' -e 's,\[,,' -e 's,\],,' $CHANNELS)
COUNT=1
ALL=`cat -n $CHANNELS | tail -n 1 | sed -e 's,^\s*,,' -e 's,\s.*,,'`
while [ "$LIST" != "" ]; do
L2=$(echo $LIST | sed -e 's,\:.*,,')
L3=$(echo $L2 | sed -e 's, ,-,' -e 's, ,-,' -e 's, ,-,' -e 's, ,-,' -e 's, ,-,')
ITEMS="$ITEMS $COUNT $L3"
PERCENT=`expr 100 \* $COUNT / $ALL`
echo $PERCENT | dialog --title "Processing" --gauge "Reading $CHANNELS\n " 6 70 0
LIST=$(echo $LIST | sed -e "s,$L2\:,,")
COUNT=`expr $COUNT + 1`
done
COUNT=`expr $COUNT - 1`
ITEMS=" 0 0 10 $ITEMS "
dialog --title "Channels" \
--msgbox "\n $COUNT channels found in $CHANNELS !" 7 70
while [ true ]; do
dialog --title "Dialog menu box" \
--menu "Choose one of the following or press <Cancel> to exit" \
$ITEMS 2> /tmp/dvbview.tst
if [ $? = 1 ]; then
rm /tmp/dvbview.tst
clear
echo "Cancelled !!!"
exit 0
fi
CHANNELNO=$(cat /tmp/dvbview.tst)
rm /tmp/dvbview.tst
DATA=`head -n $CHANNELNO $CHANNELS | tail -n 1`
FREQ=`echo $DATA | sed \
-e 's,[^\:]*\:,,' \
-e 's,\:.*,,' `
POL=`echo $DATA | sed \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,\:.*,,' `
SYM=`echo $DATA | sed \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,\:.*,,' `
VPID=`echo $DATA | sed \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,\:.*,,' `
APID=`echo $DATA | sed \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,[^\:]*\:,,' \
-e 's,\:.*,,' `
dvbstream -f $FREQ -p $POL -s $SYM -v $VPID -a $APID -o | mplayer -framedrop -zoom -fs -cache 1024 -
done
BY: Pejman Moghadam
TAG: dialog, sed, dvb, dvbstream, mplayer, bash-script, bash
DATE: 2007-12-25 00:20:03