Changeset 524 for grabbers/yahoo7web

Show
Ignore:
Timestamp:
02/15/07 00:34:55 (6 years ago)
Author:
lincoln
Message:

optimize yahoo7web: when fetching microgaps, only fetch summary pages for hours that have gaps

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • grabbers/yahoo7web

    r523 r524  
    88 
    99my $progname = "yahoo7web"; 
    10 my $version = "0.09"; 
     10my $version = "0.10"; 
    1111 
    1212use LWP::UserAgent; 
     
    480480                        next if (($currtime + (3 * 60 * 60)) < $starttime); # no point fetching the past 
    481481 
     482                        # if we are fetching microgaps, skip this summary page if we aren't 
     483                        # interested in anything from it anyway 
     484                        next if ((defined $opt->{gaps_file}) && (!window_is_within_microgap($currtime,$currtime+(60*60*3)))); 
     485 
    482486                        my $url = sprintf "http://au.tv.yahoo.com/tv-guide/?hour=%s&min=%s&date=%s&mon=%s&year=%s&tvrg=%s&next=%s", 
    483487                                POSIX::strftime("%H",localtime($starttime)), 
     
    588592                                        $progs_in_table++; 
    589593 
    590                                         # if we are fetching microgaps, skip if this isn't 
    591                                         # in a micro-gap. 
     594                                        # if we are fetching microgaps, skip if this isn't in a micro-gap. 
    592595                                        if (defined $opt->{gaps_file}) { 
    593                                                 my $found_gap_match = 0; 
    594                                                 if (defined $gaps->{$prog->{channel}}) { 
    595                                                         foreach my $g (@{($gaps->{$prog->{channel}})}) { 
    596                                                                 my ($s, $e) = split(/-/,$g); 
    597                                                                 $found_gap_match = 1 if 
    598                                                                   ((($s >= $prog->{starttime}) && ($s <= $prog->{stoptime})) || 
    599                                                                    (($e >= $prog->{starttime}) && ($e <= $prog->{stoptime})) || 
    600                                                                    (($s <= $prog->{starttime}) && ($e >= $prog->{stoptime}))); 
    601                                                         } 
    602                                                 } 
    603                                                 if (!$found_gap_match) { 
    604                                                         $stats{gaps_skipped}++; 
    605                                                         next; 
    606                                                 } else { 
    607                                                         $stats{gaps_included}++; 
    608                                                 } 
     596                                                next if (!window_is_within_microgap($prog->{starttime},$prog->{stoptime},$this_chan)); 
     597                                                $stats{gaps_included}++; 
    609598                                        } 
    610599 
     
    859848############################################################################## 
    860849 
     850sub window_is_within_microgap 
     851{ 
     852        my ($start, $stop, $channel) = @_; 
     853 
     854        return window_channel_is_within_microgap($start, $stop, $channel) if (defined $channel); 
     855 
     856        foreach my $ch (keys %{$channels}) { 
     857                return 1 if window_channel_is_within_microgap($start, $stop, $ch); 
     858        } 
     859        return 0; 
     860} 
     861 
     862sub window_channel_is_within_microgap 
     863{ 
     864        my ($start, $stop, $channel) = @_; 
     865 
     866        if (defined $gaps->{$channel}) { 
     867                foreach my $g (@{($gaps->{$channel})}) { 
     868                        my ($s, $e) = split(/-/,$g); 
     869                        return 1 if 
     870                          ((($s >= $start) && ($s <= $stop)) || 
     871                           (($e >= $start) && ($e <= $stop)) || 
     872                           (($s <= $start) && ($e >= $stop))); 
     873                } 
     874        } 
     875        $stats{gaps_skipped}++; 
     876        return 0; 
     877} 
     878 
     879############################################################################## 
     880