<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff><!--[if !mso]><![endif]-->
<DIV><FONT face=Arial size=2>Guys,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I've modified that script for Adelaide
(and done another one for Foxtel) and it seems to work for the most
part, however i get missing data in some areas - script and errors attatched -
any ideas from any coders out there?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>---</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT size=2><FONT
face="Courier New">#!/usr/bin/perl -w <BR><BR># Australian TV Guide XMLTV
grabber by Damon Searle <BR># Derived from a yahoo XMLTV grabber by Ron Kellam
which was itself... <BR># Derived from original code by Justin Hawkins <BR>#
<BR># This program is free software; you can redistribute it and/or modify <BR>#
it under the terms of the GNU General Public License as published by <BR># the
Free Software Foundation; either version 2 of the License, or <BR># (at your
option) any later version. <BR># <BR># This program is distributed in the hope
that it will be useful, <BR># but WITHOUT ANY WARRANTY; without even the implied
warranty of <BR># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<BR># GNU General Public License for more details. <BR># <BR># You should have
received a copy of the GNU General Public License <BR># along with this program;
if not, write to the Free Software <BR># Foundation, Inc., <?xml:namespace
prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:address
w:st="on"><st1:Street w:st="on">59 Temple Place, Suite 330</st1:Street>,
<st1:City w:st="on">Boston</st1:City>, <st1:State w:st="on">MA</st1:State>
<st1:PostalCode w:st="on">02111-1307</st1:PostalCode> <st1:country-region
w:st="on">USA</st1:country-region></st1:address> <BR><BR># *** Only tested with
ACT data *** </FONT></FONT></P>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT size=2><FONT
face="Courier New"># Works for the most part with Adeladie Data<BR><BR>#
Instructions: <BR># Go to http://tvguide.ninemsn.com.au/guide/ select your area
<BR># Look at the last number in the URL before ".asp" and set <BR># the region
variable below. Then put the channel names as listed <BR># on the tv guide site
into the variables below. <BR># Then set your XMLTV ids from the database in the
_XMLTVID variables. <BR><BR># If it doesn't work with mythfilldatabase, try:
<BR># tv_grab_au <BR># mythfilldatabase 1 -1 /tmp/tvguide/guide.xml
<BR><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/><o:p> </o:p></FONT></FONT></P>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"
size=2># Modified by Michael Cheshire to pick up data for Adelaide</FONT></P>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"
size=2></FONT> </P>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT size=2><FONT
face="Courier New">use strict; <BR>use Getopt::Long; <BR>use XMLTV; <BR>use
LWP::Simple; <BR>use Date::Manip; <BR>use File::Path; <BR><BR># Variables
<BR><BR>my $days_to_grab = 7; <BR>my $region = "81"; # 126 = ACT, 123 = Fox, 83
= <st1:City w:st="on"><st1:place w:st="on">Adelaide</st1:place></st1:City>
<BR>my $guide_url = "http://tvguide.ninemsn.com.au/guide/"; <BR>my $details_url
= "http://tvguide.ninemsn.com.au/closeup/default.asp?pid="; <BR>my $cache_dir =
"/tmp/tvguide.fta"; <BR>my $offset = "+0930"; <BR><BR>my $ABC = "ABC SA"; <BR>my
$Prime = "Channel Seven Adelaide"; #Channel 7 in Sydney/Melbourne/etc <BR>my
$SBS = "SBS"; <BR>my $Ten = "Network TEN Adelaide"; <BR>my $WIN = "Channel Nine
Adelaide"; #Channel 9 in Sydney/Melbourne/etc <BR><BR>#my $ABC_XMLTVID =
"freesd.Canberra.2.d1.com.au"; <BR>#my $Prime_XMLTVID =
"freesd.Canberra.7.d1.com.au"; <BR>#my $SBS_XMLTVID =
"freesd.Canberra.SBS.d1.com.au"; <BR>#my $Ten_XMLTVID =
"freesd.Canberra.10.d1.com.au"; <BR>#my $WIN_XMLTVID =
"freesd.Canberra.9.d1.com.au"; <BR><BR>my $ABC_XMLTVID =
"free.Adelaide.2.d1.com.au"; <BR>my $Prime_XMLTVID =
"free.Adelaide.7.d1.com.au"; <BR>my $SBS_XMLTVID =
"free.Adelaide.SBS.d1.com.au"; <BR>my $Ten_XMLTVID =
"free.Adelaide.10.d1.com.au"; <BR>my $WIN_XMLTVID = "free.Adelaide.9.d1.com.au";
<BR><BR>my $opt_days; <BR>my $opt_output; <BR><BR>GetOptions('days=i' =>
\$opt_days, <BR>'output=s' => \$opt_output <BR>); <BR><BR>if ($opt_days) {
<BR>$days_to_grab = $opt_days <BR>} <BR><BR>if (!($opt_output)) {
<BR>$opt_output = $cache_dir . "/guide.xml"; <BR>} <BR><BR><BR>print
"$days_to_grab, $opt_output\n"; <BR>#exit(0); <BR><BR><BR>my $currentday =
&ParseDate("today"); <BR>my $prog_ref; <BR>my $chan_ref;
<BR><BR>$$chan_ref{$ABC} = { <BR>'id' => $ABC_XMLTVID, <BR>'display-name'
=> [ [ $ABC, undef ]]}; <BR>$$chan_ref{$Prime} = { <BR>'id' =>
$Prime_XMLTVID, <BR>'display-name' => [ [ $Prime, undef ]]};
<BR>$$chan_ref{$SBS} = { <BR>'id' => $SBS_XMLTVID, <BR>'display-name' => [
[ $SBS, undef ]]}; <BR>$$chan_ref{$Ten} = { <BR>'id' => $Ten_XMLTVID,
<BR>'display-name' => [ [ $Ten, undef ]]}; <BR>$$chan_ref{$WIN} = { <BR>'id'
=> $WIN_XMLTVID, <BR>'display-name' => [ [ $WIN, undef ]]}; <BR><BR>my
$day_counter = 1; <BR>while ($day_counter <= $days_to_grab) <BR>{ <BR>my
$date = &UnixDate($currentday, "%d%m%Y"); <BR>my @day_lines =
get_day($date); <BR>my @pids; <BR>foreach my $line (@day_lines) <BR>{
<BR>foreach my $link (split /\n|tr|TR|TD|tr/, $line ) <BR>{ <BR>if ($link =~
/closeup\/default.asp/) <BR>{ <BR>$link =~ s/.+pid=//g; <BR>$link =~ s/".+//g;
<BR>if ($link =~ /\d+/) <BR>{ <BR>push @pids, $link; <BR>} <BR>} <BR>} <BR>}
<BR><BR>foreach my $pid (@pids) <BR>{ <BR>my @details = get_details($date,
$pid); <BR><BR>my $show_details_table = ""; <BR>my $use_line = 0; <BR>foreach my
$line (@details) <BR>{ <BR>if ($line =~ /bgColor=#f7f3e8/) <BR>{ <BR>$use_line =
0; <BR>} <BR>if ($use_line == 1) <BR>{ <BR>$show_details_table .= $line; <BR>}
<BR>if ($line =~ /bgcolor=#ffffff/) <BR>{ <BR>$use_line = 1; <BR>} <BR><BR>}
<BR><BR>$show_details_table =~ s/<[^>]*>/\n/g; <BR>$show_details_table
=~ s/\&nbsp\;//g; <BR>#$show_details_table =~
s/<BR>|<TR>|<TD><B><b><\/B><\/b>/\n/g;
<BR>#$show_details_table =~ s/Genre://g; <BR>#$show_details_table =~
s/Rated:/\n/g; <BR>my $count = 0; <BR><BR>my $channel = ""; <BR>my $start_date =
&UnixDate($currentday, "%Y-%m-%d"); <BR>my $time; <BR>my $title1 = "";
<BR>my $title2 = ""; <BR>my $genre = ""; <BR>my $descr = ""; <BR>my $details =
""; <BR>my $duration; <BR><BR><BR>#print $show_details_table. "\n\n\n";
<BR>foreach my $line (split /\n/, $show_details_table) <BR>{ <BR>if ($count ==
4){ <BR>#print "Time: " . $line . "\n"; <BR>$time = $line; <BR>} <BR>elsif
($count == 7){ <BR>$channel = $line; <BR>#print "Channel: " . $line . "\n";
<BR>} <BR>elsif ($count == 19){ <BR>$title1 = $line; <BR>#print "Program: " .
$line . "\n"; <BR>} <BR>elsif ($count == 20){ <BR>$line =~ s/ - //g; <BR>$title2
= $line; <BR>#print "Subtitle: " . $line . "\n"; <BR>} <BR>elsif ($count == 21){
<BR>$line =~ s/\D//g; <BR>$duration = $line; <BR>#print "Run time: " . $line .
"\n"; <BR>} <BR>elsif ($count == 22){ <BR>$line =~ s/[^A-Z]//g; <BR>$details =
$line; <BR>#print "Rating: " . $line . "\n"; <BR>} <BR>elsif ($count == 26){
<BR>$line =~ s/ //g; <BR>$genre = $line; <BR>#print "Genre: " . $line . "\n";
<BR>} <BR>elsif ($count == 28 && $line =~ /[a-zA-Z]/){ <BR>$descr =
$line; <BR>#print "Description: " . $line . "\n"; <BR>} <BR>#elsif ($count == 26
&& $line =~ /[a-zA-Z]/){ <BR># $descr = $line; <BR># print "Description:
" . $line . "\n"; <BR>#} <BR>#print $count .": " . $line . "\n"; <BR>++$count;
<BR>} <BR><BR>my $start_time = &UnixDate($time, "%H:%M"); <BR>my
$start_datetime = $start_date . " " . $start_time; <BR>if ($start_time =~
/00:|01:|02:|03:|04:|05:/) <BR>{ <BR>$start_date = &DateCalc($start_date, "+
1 day"); <BR>} <BR>$start_date = &UnixDate($start_date, "%Y%m%d"); <BR>my
$end_time = &DateCalc($start_time, " + " . $duration . "minutes");
<BR>$end_time = &UnixDate($end_time, "%H:%M"); <BR><BR>my $end_date; <BR>if
(&Date_Cmp($start_time, $end_time) <= 0) <BR>{ <BR>$end_date =
$start_date; <BR>} <BR>else <BR>{ <BR>my $err; <BR>my $edate =
&DateCalc($start_date, "+ 1 day", \$err); <BR>$end_date =
&UnixDate($edate, "%Y%m%d"); <BR>} <BR><BR>if ($channel =~ /$ABC/) <BR>{
<BR>$channel = $ABC_XMLTVID; <BR>} <BR>elsif ($channel =~ /$Prime/) <BR>{
<BR>$channel = $Prime_XMLTVID; <BR>} <BR>elsif ($channel =~ /$SBS/) <BR>{
<BR>$channel = $SBS_XMLTVID; <BR>} <BR>elsif ($channel =~ /$Ten/) <BR>{
<BR>$channel = $Ten_XMLTVID; <BR>} <BR>elsif ($channel =~ /$WIN/) <BR>{
<BR>$channel = $WIN_XMLTVID; <BR>} <BR>my $start; <BR>my $stop; <BR><BR>$start =
$start_date . &UnixDate($start_time,"%H%M") . "00 " . $offset; <BR>$stop =
$end_date . &UnixDate($end_time,"%H%M") . "00 +0930"; <BR><BR>my $a_prog = {
<BR>channel => $channel, <BR>start => $start, <BR>stop => $stop,
<BR>title => [ [ $title1, undef ] ] <BR>}; <BR><BR>$descr =~ s/^\s+//;
<BR>$descr =~ s/\s+$//; <BR><BR>if ($title2) { $$a_prog{'sub-title'} = [ [
$title2, undef ] ]; } <BR>if ($descr) { $$a_prog{desc} = [ [ $descr, undef ] ];
} <BR>if ($genre) { $$a_prog{category} = [ [ $genre, undef ] ]; } <BR><BR>push
@$prog_ref, $a_prog; <BR>} <BR><BR><BR><BR>$day_counter++; <BR>$currentday =
&DateCalc($currentday, "+ 1 day"); <BR>} <BR><BR>my $data = [
<BR>'ISO-8859-1', <BR>{ <BR>'source-info-name' =>
'http://tvguide.ninemsn.com.au/', <BR>'generator-info-name' => 'NineMSN
grabber', <BR>'generator-info-url' => '', <BR>'generator-info-name' =>
"XMLTV - tv_grab_au NineMSN v0.1" <BR>}, <BR>$chan_ref, <BR>$prog_ref <BR>];
<BR><BR><BR>#my $outfile = $cache_dir . "/guide.xml"; <BR>my $outfile =
$opt_output; <BR><BR>my $fh = new IO::File ">$outfile";
<BR>XMLTV::write_data($data, OUTPUT=>$fh); <BR><BR># download the guide for
the date to file <BR>sub get_day <BR>{ <BR>my $date = $_[0]; <BR>my $url =
$guide_url . $date . "_" . $region . ".asp"; <BR><BR>my $guide_dir = $cache_dir
. "/" . $date; <BR>my $guide_file = $guide_dir . "/guide.html"; <BR><BR>if (!(-e
$guide_file)) <BR>{ <BR>mkpath ($guide_dir); <BR>getstore($url, $guide_file);
<BR>} <BR>open(GUIDE, $guide_file); <BR>my @guide_lines = <GUIDE>;
<BR>close(GUIDE); <BR>return @guide_lines; <BR>} <BR><BR>sub get_details <BR>{
<BR>my $date = $_[0]; <BR>my $program_id = $_[1]; <BR><BR>my $url = $details_url
. $program_id; <BR>my $guide_dir = $cache_dir . "/" . $date; <BR>my
$details_file = $guide_dir . "/" . $program_id . ".html"; <BR><BR>if (!(-e
$details_file)) <BR>{ <BR>mkpath ($guide_dir); <BR>getstore($url,
$details_file); <BR>} <BR><BR>open(DETAILS, $details_file); <BR>my
@details_lines = <DETAILS>; <BR>close(DETAILS); <BR>return @details_lines;
<BR>} </FONT></FONT></P>
<P class=MsoPlainText style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"
size=2></FONT> </P><FONT size=2><FONT
face="Courier New"></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New">---</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT face=Arial>Errors I get running
the script : </FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial></FONT></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT face=Arial>7,
/tmp/tvguide.fta/guide.xml<BR>readline() on closed filehandle DETAILS at
/usr/bin/tv_guide_au_fta line 345.<BR>Use of uninitialized value in
concatenation (.) or string at /usr/bin/tv_guide_au_fta line 220.<BR>Use of
uninitialized value in pattern match (m//) at /usr/bin/tv_guide_au_fta line
221.<BR>Use of uninitialized value in concatenation (.) or string at
/usr/bin/tv_guide_au_fta line 226.<BR>Use of uninitialized value in
concatenation (.) or string at /usr/bin/tv_guide_au_fta line 264.<BR>Use of
uninitialized value in concatenation (.) or string at /usr/bin/tv_guide_au_fta
line 265.<BR>readline() on closed filehandle DETAILS at /usr/bin/tv_guide_au_fta
line 345.<BR>Use of uninitialized value in concatenation (.) or string at
/usr/bin/tv_guide_au_fta line 220.<BR>Use of uninitialized value in pattern
match (m//) at /usr/bin/tv_guide_au_fta line 221.<BR>Use of uninitialized value
in concatenation (.) or string at /usr/bin/tv_guide_au_fta line 226.<BR>Use of
uninitialized value in concatenation (.) or string at /usr/bin/tv_guide_au_fta
line 264.<BR>Use of uninitialized value in concatenation (.) or string at
/usr/bin/tv_guide_au_fta line 265.<BR>title element: not writing empty content
for title at /usr/share/perl5/XMLTV.pm line 1730.<BR>bad data inside programme
element, not writing<BR>title element: not writing empty content for title at
/usr/share/perl5/XMLTV.pm line 1730.<BR>bad data inside programme element, not
writing<BR></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial>---</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial></FONT></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT face=Arial>Any ideas anyone? -
I can post you the /tmp files if you require. </FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial></FONT></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial>:)</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT
face=Arial></FONT></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT face=Arial>M.</DIV></FONT>
<P class=MsoPlainText
style="MARGIN: 0cm 0cm 0pt"><BR><o:p> </o:p></FONT></FONT></P></BODY></HTML>