All pastes #331195 Raw Edit

mtv script

public shellscript v1 · immutable
#331195 ·published 2007-01-28 17:35 UTC
rendered paste body
#!/bin/bash## Copyright (C) 2006 Marios Andreopoulos - mrsaccess# Distributed under the terms of the GNU General Public License v2# ### mtv is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY# OTHER  KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.# See the GNU General Public License for more details.### Version notice:#  There aren't any known bugs in this script.###system_encoding="utf8"prog_name="mtv"prog_version="0.1"release_name="The truth is out there."fullprog="${prog_name}-${prog_version}"DaTe=`date +%Y-%m-%d`i_am=`whoami`rawdata=/tmp/$i_am-mtv1list1=/tmp/$i_am-mtv2list2=/tmp/$i_am-mtv3list3=/tmp/$i_am-mtv4#Setting some color codesGR=$'\x1b[1;32m'RED=$'\x1b[31m'REDB=$'\x1b[31;1m'TQ=$'\x1b[36;1m'TQB=$'\x1b[36;1;5m'YL=$'\x1b[33;1m'NC=$'\x1b[0m'version_info(){cat <<END ${prog_name}, version ${prog_version} codename ${TQB}$release_name${NC} Copyright (C) 2006 Marios Andreopoulos - mrsaccess  This is free software.  You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. in.gr webiste is copyright of Lambrakis PressEND}tvguide(){echo -e "&#934;&#972;&#961;&#964;&#969;&#963;&#951; &#960;&#961;&#959;&#947;&#961;&#940;&#956;&#956;&#945;&#964;&#959;&#962; &#945;&#960;&#972; &#964;&#959; in.gr.\n\n"ls $rawdata >/dev/null 2>&1if ((`echo $?`!=0)); then echo hi > $rawdatafiif [ `head -n1 $rawdata` != "$DaTe" ]; then  echo hi  echo $DaTe > $rawdata    wget -O - "http://www.in.gr/TV/results.asp?dtmDate=$DaTe"|iconv -f iso-8859-7 -t $system_encoding >> $rawdataficleargrep ChannelID $rawdata|grep -vE "class|size"|sort -u|sed -e 's/.*ChannelID=\(.*\)">\(.*\)<\/a.*/ \2/'|grep -E -n "[0-9A-Za-z&#945;-&#969;&#913;-&#937;]"number_of_channels=`grep ChannelID $rawdata|grep -vE "class|size"|sort -u|sed -e 's/.*ChannelID=\(.*\)">\(.*\)<\/a.*/ \2/'|grep -E -n "[0-9A-Za-z&#945;-&#969;&#913;-&#937;]"|wc -l`echo -en "\n&#917;&#960;&#953;&#955;&#941;&#958;&#964;&#949; &#954;&#945;&#957;&#940;&#955;&#953; &#954;&#945;&#953; &#960;&#953;&#941;&#963;&#964;&#949; ENTER: ";read -s -n3 channel_numberchannel_number=`echo $channel_number|sed -e 's/^[0]*//'`if [[ "$channel_number" -lt "1" ]]; then echo -e "\n\n&#923;&#940;&#952;&#959;&#962; &#954;&#945;&#957;&#940;&#955;&#953;."; exit; fiif [[ "$channel_number" -gt "$number_of_channels" ]]; then echo -e "\n\n&#923;&#940;&#952;&#959;&#962; &#954;&#945;&#957;&#940;&#955;&#953;."; exit; fiChannel=`grep ChannelID $rawdata|grep -vE "class|size"|sort -u|sed -e 's/.*ChannelID=\(.*\)">\(.*\)<\/a.*/\1/'|sed -n ${channel_number}p`clearecho -e "&#932;&#959; &#960;&#961;&#972;&#947;&#961;&#945;&#956;&#956;&#945; &#964;&#959;&#965; &#954;&#945;&#957;&#945;&#955;&#953;&#959;&#973; `grep ChannelID $rawdata|grep -vE "class|size"|sort -u|sed -e 's/.*ChannelID=\(.*\)">\(.*\)<\/a.*/\2/'|sed -n ${channel_number}p` &#947;&#953;&#945; &#964;&#953;&#962; $DaTe:"grep -v class $rawdata|grep -C3 "ID=$Channel"|sed -e 's/<td>\(.*\)<\/td>/\1/'|sed -e 's/<a \(.*\)">\(.*\)<\/a>/\2/'|sed -n 1~8p|sed 's/[\t]*//' > $list1grep -v class $rawdata|grep -C3 "ID=$Channel"|sed -e 's/<td>\(.*\)<\/td>/\1/'|sed -e 's/<a \(.*\)">\(.*\)<\/a>/\2/'|sed -n 2~8p|sed 's/[\t]*//' > $list2grep -v class $rawdata|grep -C3 "ID=$Channel"|sed -e 's/<td>\(.*\)<\/td>/\1/'|sed -e 's/<a \(.*\)">\(.*\)<\/a>/\2/'|sed -n 6~8p|sed 's/[\t]*//' > $list3for ((i=1; i<=`cat $list1|wc -l`; i++)); do echo -e "`sed -n ${i}p $list1`\t`sed -n ${i}p $list2`\t\t\t\t\t\t\t`sed -n ${i}p $list3`"; donerm -f $list1 $list2 $list3}for ((i=$OPTIND; i<=$#; ++i)); do  case ${!i} in    -v | --version    ) version_info; exit;;    -h | --help       ) help_info; exit;;    * ) echo -e " Sorry, $prog_name was called with unknown argument(s).\n Try again without any arguments. ;)"; exit;;  esacdonetvguide