[mythtv-users] tv_grab_au 2.3

Michael Fox michaelf at users.heimic.net
Wed Jun 28 11:59:52 UTC 2006


On 28/06/2006, at 9:01 PM, Paul Andreassen wrote:

>
> Something like this should work.
>
> Paul
> --  
> --- tv_grab_au.orig	2006-06-28 20:59:11.068985600 +1000
> +++ tv_grab_au	2006-06-28 20:59:24.033014768 +1000
> @@ -883,15 +883,43 @@
>
>  #  
> ---------------------------------------------------------------------- 
> -----
>  # --- get NMSN guide for given date (perversely "ddmmYYYY")
> +my $ua;
>  sub get_guide_page {
>    my $service = shift;
>    my $date = shift;
> -  my $url = "$NMSN/guide/${date}_$service->{regionid}.asp?"
> -    . "channel=$service->{name}" . MSID();
> +  my $url;
> +  if (not $service->{URL}) {
> +    if ($service->{name} eq 'free') {
> +      $url = "${NMSN}/setlocation.asp?region=$service->{regionid}" .
> +       "&returnURL=${TVTODAY}?channel=$service->{name}" . MSID();
> +    } else {
> +      $url = $TVTODAY .
> +        "?channel=$service->{name}&region=$service->{regionid}" .  
> MSID();
> +    }
> +  } elsif ($service->{URL} eq "unknown") {
> +    $url = "$NMSN/guide/${date}_$service->{regionid}.asp?"
> +      . "channel=$service->{name}" . MSID();
> +  } else {
> +    $url = $service->{URL};
> +  }
> +  $ua->cookie_jar($service->{cookie_jar}||{});
> +
>    print "GET_GUIDE_PAGE($url)\n" if $debug;
> -  my $page = get_page($url) or
> +  my $page = get_page($url);
> +
> +  $service->{cookie_jar}=$ua->cookie_jar;
> +  $service->{URL} = "unknown";
> +  if ($page) {
> +    ++$count{guide};
> +    my $next = $page;
> +    if ($next =~ s/.*href="([^"]*?)".*?>Tomorrow's TV<.*/$1/i) {
> +      $service->{URL}=$NMSN . $next . MSID();
> +    } else {
> +      print "Warning: Failed to get url for next day\n";
> +    }
> +  } else {
>      print "Warning: Failed to get program listing for day $date\n";
> -  ++$count{guide} if $page;
> +  }
>    return $page;
>  }
>
> @@ -918,7 +946,6 @@
>  #  
> ---------------------------------------------------------------------- 
> -----
>  # get a page and its base (and report all redirections if debugging)
>  # we attempt 5 times with 3 second pauses between failures.
> -my $ua;
>  BEGIN {
>    $ua = LWP::UserAgent->new
>      ('timeout' => 30,


Nice patch Paul.

Just patched my tv_grab_au and did a run just now;

root at bart:~# /etc/cron.daily/mythtv-backend
2006-06-28 21:53:26.507 New DB connection, total: 1
2006-06-28 21:53:26.519 New DB connection, total: 2
2006-06-28 21:53:26.521 New DB connection, total: 3
tv_grab_au 2.3: grabbing 7 days into /tmp/mythg5Pr2u
tv_grab_au: downloads = 7 guide pages, 418 detail pages
   0 failed detail pages, 877 pages found in cache, 1 stop times  
adjusted
tv_grab_au: 5571.82 KB downloaded
tv_grab_au: finished in 310 seconds
2006-06-28 21:58:36.660 New DB connection, total: 4
2006-06-28 21:58:38.351 New DB connection, total: 5
2006-06-28 21:58:40.661 Connecting to backend server:  
192.168.7.15:6543 (try 1 of 5)
2006-06-28 21:58:40.667 Using protocol version 15

Of course its working sweet again (and to ninemsn developers who  
might be lurking... hahaha you've been had again)..


More information about the mythtv-users mailing list