The PERL xmltv grabber for .hu and .ro packaged with the original xmltv distribution is rather slow and buggy so I've decided to write my own using AWK and of course bash.
#!/bin/bash WGET="wget -q -O- " get_channel_list() { list=`$WGET "http://www.port.hu/pls/tv/tv.channel?i_ch=1&i_days=1&i_xday=1&i_where=1"` # echo -e "$list" | egrep -zo '<select name="i_ch".*</select>' | awk '/value="[0-9]+">.*<\/option>/ { print $1 }' # echo -e "$list" | tr -d '\n' | egrep -o '<select name="i_ch".*</select>' | sed echo -e "$list" | awk '\ BEGIN{a=0} \ /<select name="i_ch"/{a=1} \ a==1 && /value/ { \ split($0,b,/value="/); \ chan=b[2] + 0; \ split($0,b,/value="[0-9]+">/); \ split(b[2],c,/<\/option>/); \ name=c[1]; \ print chan "\t" name; \ } \ /<\/select>/{a=0} \ ' | sort -n | sed "s/&/&/g" } channels=`get_channel_list` # print header cat <<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE tv SYSTEM "xmltv.dtd"> <tv source-info-url="http://www.port.hu/" source-data-url="http://www.port.hu" generator-info-name="XMLTV_MCREE" generator-info-url="http://www.tricon.hu/~mcree"> EOF # print channel list echo -e "$channels" | while read channel; do id=`echo -e "$channel" | cut -f1` name=`echo -e "$channel" | cut -f2` echo "<channel id=\"$id\">" echo " <display-name lang=\"hu\">$name</display-name>" echo "</channel>" done # get programmes for day in -1 +0 +1 +2 +3; do offset=$(( $day + 1 )) date=`date +%Y%m%d -d"now $day days"` nextdate=`date +%Y%m%d -d"now $day days"` zone=`date +%z` echo -e "$channels" | while read channel; do id=`echo -e "$channel" | cut -f1` name=`echo -e "$channel" | cut -f2` programmes=`$WGET "http://www.port.hu/pls/tv/tv.channel?i_ch=$id&i_days=$offset&i_xday=1&i_where=1"` echo -e "$programmes" | awk '\ /<tr/{tr=1} tr==1 && /<td.*<span class="btxt"/ {\ match($0,/([0-9]+:[0-9]+)/,a);\ split(a[1],d,/:/);\ if (d[1]!=0) {date="'$date'"} else {date="'$nextdate'"}; \ print "<programme start=\"" date d[1] d[2] "00 '$zone'\" channel=\"'$id'\">";\ getline;\ res=split($0,a,/(<[^>]*>)/);\ c=0;\ for (b=0;b<res;b++) \ if (a[b] ~ /\w/) \ if (c==0) {\ c=1; \ print "<title lang=\"hu\">" a[b] "</title>"\ } else {\ if (c==1) { c=2; print "<desc lang=\"hu\">"}\ print a[b]\ };\ if (c>1) print "</desc>"; \ print "</programme>"; \ }\ /<\/tr>{tr=0}/ ' | sed "s/&/&/g" done done # print footer cat <<EOF </tv> EOF