#!/usr/bin/perl -w
# Australian TV Guide XMLTV grabber by Damon Searle
# Derived from a yahoo XMLTV grabber by Ron Kellam which was itself...
# Derived from original code by Justin Hawkins
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# *** Only tested with ACT data ***
# Instructions:
# Go to http://tvguide.ninemsn.com.au/guide/ select your area
# Look at the last number in the URL before ".asp" and set
# the region variable below. Then put the channel names as listed
# on the tv guide site into the variables below.
# Then set your XMLTV ids from the database in the _XMLTVID variables.
# If it doesn't work with mythfilldatabase, try:
# tv_grab_au
# mythfilldatabase 1 -1 /tmp/tvguide/guide.xml
use strict;
use XMLTV;
use LWP::Simple;
use Date::Manip;
use File::Path;
# Variables
my $days_to_grab = 7;
my $region = "126"; # 126 = ACT
my $guide_url = "http://tvguide.ninemsn.com.au/guide/";
my $details_url = "http://tvguide.ninemsn.com.au/closeup/default.asp?pid=";
my $cache_dir = "/tmp/tvguide";
my $offset = "+1000";
my $ABC = "ABC NSW";
my $Prime = "Prime Southern"; #Channel 7 in Sydney/Melbourne/etc
my $SBS = "SBS Sydney";
my $Ten = "Southern Cross TEN Capital";
my $WIN = "WIN Television NSW"; #Channel 9 in Sydney/Melbourne/etc
my $ABC_XMLTVID = "freesd.Canberra.2.d1.com.au";
my $Prime_XMLTVID = "freesd.Canberra.7.d1.com.au";
my $SBS_XMLTVID = "freesd.Canberra.SBS.d1.com.au";
my $Ten_XMLTVID = "freesd.Canberra.10.d1.com.au";
my $WIN_XMLTVID = "freesd.Canberra.9.d1.com.au";
my $currentday = &ParseDate("today");
my $prog_ref;
my $chan_ref;
$$chan_ref{$ABC} = {
'id' => $ABC_XMLTVID,
'display-name' => [ [ $ABC, undef ]]};
$$chan_ref{$Prime} = {
'id' => $Prime_XMLTVID,
'display-name' => [ [ $Prime, undef ]]};
$$chan_ref{$SBS} = {
'id' => $SBS_XMLTVID,
'display-name' => [ [ $SBS, undef ]]};
$$chan_ref{$Ten} = {
'id' => $Ten_XMLTVID,
'display-name' => [ [ $Ten, undef ]]};
$$chan_ref{$WIN} = {
'id' => $WIN_XMLTVID,
'display-name' => [ [ $WIN, undef ]]};
my $day_counter = 1;
while ($day_counter <= $days_to_grab)
{
my $date = &UnixDate($currentday, "%d%m%Y");
my @day_lines = get_day($date);
my @pids;
foreach my $line (@day_lines)
{
foreach my $link (split /\n|tr|TR|TD|tr/, $line )
{
if ($link =~ /closeup\/default.asp/)
{
$link =~ s/.+pid=//g;
$link =~ s/".+//g;
if ($link =~ /\d+/)
{
push @pids, $link;
}
}
}
}
foreach my $pid (@pids)
{
my @details = get_details($date, $pid);
my $show_details_table = "";
my $use_line = 0;
foreach my $line (@details)
{
if ($line =~ /bgColor=#f7f3e8/)
{
$use_line = 0;
}
if ($use_line == 1)
{
$show_details_table .= $line;
}
if ($line =~ /bgcolor=#ffffff/)
{
$use_line = 1;
}
}
$show_details_table =~ s/<[^>]*>/\n/g;
$show_details_table =~ s/\ \;//g;
#$show_details_table =~ s/
|