Changeset 1420

Show
Ignore:
Timestamp:
07/02/12 16:46:33 (11 months ago)
Author:
max
Message:

News: v3.0, fix for datasource change

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/grabbers/news

    r1405 r1420  
    44# 
    55 
    6 my $version  = '2.0'; 
     6my $version  = '3.0'; 
    77 
    88use strict; 
     
    3030 
    3131my $DATASOURCE             = "http://guides.news.com.au"; 
    32 my $DATASOURCE_SETUP       = "$DATASOURCE/television/profile/?action=saveProfile"; 
     32my $DATASOURCE_SETUP       = "$DATASOURCE/television/profile/"; 
     33my $DATASOURCE_CHANNEL_LIST= "$DATASOURCE/television/profile/ajax.cfm?"; 
    3334my $DATASOURCE_GUIDE       = "$DATASOURCE/television/guide/"; 
    3435my $DATASOURCE_GUIDE_TODAY = "$DATASOURCE/television/guide/?action=restofday"; 
     
    9495} 
    9596 
    96 if ($debug or $opt->{'show-config'}) 
    97 { 
    98   show_config(); 
    99   exit 0 if ($opt->{'show-config'}); 
    100 } 
     97show_config(); 
     98exit 0 if ($opt->{'show-config'}); 
    10199 
    102100restore_cache(); 
     
    382380  $ua = Shepherd::Common::setup_ua( cookie_jar => 1 ); 
    383381 
     382  # Get list of 'venue IDs', which are the source's 
     383  # internal channel ID numbers. 
     384 
     385  print "Looking for venue IDs...\n" if ($debug); 
     386 
     387  my $html = &get_page(url => $DATASOURCE_CHANNEL_LIST, retries => 4, postvars => [ 'action' => 'channels', 'region_id' => $opt->{'region'}, 'showsub' => '0' ]); 
     388  unless ($html) 
     389  { 
     390      print "Unable to fetch channel list. Exiting.\n"; 
     391      die "Unable to fetch channel list (no network?)"; 
     392  } 
     393 
     394  my @venue_ids; 
     395  my $tree = HTML::TreeBuilder->new_from_content($html); 
     396  my %clist = %$channels; 
     397  foreach my $tag ($tree->look_down('_tag' => 'label')) 
     398  { 
     399      my $channel_name = &strip_whitespace($tag->as_text); 
     400      if ($channels->{$channel_name}) 
     401      { 
     402          # We want this channel 
     403          $tag->as_HTML =~ /venue_id__(\d+)/; 
     404          push @venue_ids, $1; 
     405 
     406          delete $clist{$channel_name}; 
     407      } 
     408  } 
     409 
     410  unless (@venue_ids) 
     411  { 
     412      print "No wanted channels found? Exiting.\n"; 
     413      die "No wanted channels found."; 
     414  } 
     415 
     416  if (keys %clist) 
     417  { 
     418      print "\n!!! WARNING! Could not find venue IDs for channels: " . join(', ', keys %clist) . ".\n\n"; 
     419  } 
     420 
     421  print "Venue IDs: " . join(',', @venue_ids) . "\n" if ($debug); 
     422 
    384423  # Set region/service cookie 
    385   unless (get_page(url => $DATASOURCE_SETUP, retries => 4, postvars => [ 'fta_region_id' => $opt->{'region'} ])) 
     424  my $postvars = [ 'action' => 'saveProfile', 'fta_region_id' => $opt->{'region'} ]; 
     425  foreach (@venue_ids) 
     426  { 
     427      push @$postvars, 'venue_id', $_; 
     428  } 
     429 
     430  unless (&get_page(url => $DATASOURCE_SETUP, retries => 4, postvars => $postvars )) 
    386431  { 
    387432      print "Unable to fetch profile page. No network? Exiting.\n"; 
  • trunk/status

    r1419 r1420  
    55reference       Shepherd/Configure.pm   0.30 
    66reference       Shepherd/json_pp.pm 0.2 
    7 grabber         news                2.0 
     7grabber         news                3.0 
    88grabber         oztivo              2.50 
    99grabber         yahoo7widget        2.28