Changeset 943

Show
Ignore:
Timestamp:
10/09/07 22:10:39 (6 years ago)
Author:
paul
Message:

rex: call print_stats, cache guide pages for 3 hours, put 'movie' last, use subrating sub, capture director writer country language, fix previously-shown aspect subtitles premiere quality, don't append to description
Common.pm: add subrating sub
southerncross_website: remove subrating sub

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/grabbers/rex

    r942 r943  
    33# "Rex" 
    44 
    5 my $version  = '3.5.10'; 
     5my $version  = '3.6.0'; 
    66 
    77# An Australian TV Guide Grabber (a.k.a. tv_grab_au) 
     
    9292# 3.5.9   : Code change: use Shepherd::Common::read/write cache 
    9393# 3.5.10  : Bugfix : don't exit on unknown option 
     94# 3.6.0   : Code change: use Shepherd::Common::print_stats 
     95#           Feature: cache guide pages for 3 hours, add subratings, 
     96#           Feature: capture director, writer, country, language 
     97#           Bugfix : fix previously-shown, aspect, subtitles, premiere, quality 
    9498 
    9599use strict; 
     
    212216print stats(1); 
    213217 
     218Shepherd::Common::print_stats($progname, $version, $runtime, %stats); 
     219 
    214220exit 0; 
    215221 
     
    242248      # Special bandwidth-saving URL for day 0 
    243249 
    244       $guidedata = get_page($DATASOURCE_GUIDE_TODAY); 
     250      my $cacheid = $DATASOURCE_GUIDE_TODAY; 
     251      if ($cached->{$cacheid}) { 
     252        $guidedata = $cached->{$cacheid}->{data}; 
     253      } else { 
     254        $guidedata = get_page($DATASOURCE_GUIDE_TODAY); 
     255        if ($guidedata) { 
     256          $cached->{$cacheid}->{data} = $guidedata; 
     257          $cached->{$cacheid}->{stop} = POSIX::strftime("%Y%m%d%H%M%S", localtime($runtime)); 
     258          $cached->{$cacheid}->{title}[0][0] = $cacheid; 
     259        } 
     260      } 
    245261      parse_guide($guidedata, $date) if ($guidedata); 
    246262    } 
     
    251267      for (1 .. 4) 
    252268      { 
    253         $guidedata = get_page(url => $DATASOURCE_GUIDE, 
    254                         postvars =>  
    255                         [ 'action' => "sessionTimes", 
    256                           'region_id' => $rid, 
    257                           'date' => $date, 
    258                           'period' => $_, 
    259                           'submit' => 'submit' 
    260                         ]); 
    261         parse_guide($guidedata, $date, $_) if ($guidedata); 
     269        my $cacheid = "${DATASOURCE_GUIDE}?r=${rid}&d=${date}&p=$_"; 
     270        if ($cached->{$cacheid}) { 
     271          $guidedata = $cached->{$cacheid}->{data}; 
     272        } else { 
     273          $guidedata = get_page(url => $DATASOURCE_GUIDE, 
     274                        postvars => 
     275                        [ 'action' => "sessionTimes", 
     276                          'region_id' => $rid, 
     277                          'date' => $date, 
     278                          'period' => $_, 
     279                          'submit' => 'submit' 
     280                        ]); 
     281          if ($guidedata) { 
     282            $cached->{$cacheid}->{data} = $guidedata; 
     283            $cached->{$cacheid}->{stop} = POSIX::strftime("%Y%m%d%H%M%S", localtime($runtime)); 
     284            $cached->{$cacheid}->{title}[0][0] = $cacheid; 
     285          } 
     286        } 
     287        parse_guide($guidedata, $date, $_) if ($guidedata); 
    262288      } 
    263289    } 
     
    513539sub clean_cache 
    514540{ 
    515     my $r = expand_date(localtime(time() - 3600).""); 
     541    my $r = expand_date(localtime(time() - 3*3600).""); 
    516542    my $c = 0; 
    517543    print "Removing cache items that finish earlier than $r.\n" if ($debug); 
     
    818844      if ($str and $str->as_text() =~ /movie/i) 
    819845      { 
    820         unshift (@extra, 'movie'); 
     846        push (@extra, 'movie'); 
    821847      } 
    822848 
     
    837863          $_ = [ $_, 'advisory', undef ]; 
    838864        } 
    839         $show->{'rating'} = [[ $1, 'ABA', undef],  @extra ]; 
     865        my $sr = &Shepherd::Common::subrating($2); 
     866        $show->{'rating'} = [[ $sr ? "$1 $sr" : $1, 'ABA', undef],  @extra ]; 
    840867      } 
    841868      else 
     
    848875      $show->{'credits'}{'actor'} = [ split(/, /, strip_whitespace($1)) ]; 
    849876    } 
     877    elsif ($str =~ /Director: (.+)/) 
     878    { 
     879      $show->{'credits'}{'director'} = [ split(/, /, strip_whitespace($1)) ]; 
     880    } 
     881    elsif ($str =~ /Writer: (.+)/) 
     882    { 
     883      $show->{'credits'}{'writer'} = [ split(/, /, strip_whitespace($1)) ]; 
     884    } 
    850885    elsif ($str =~ /Year:\s*(\d+)/) 
    851886    { 
    852887      $show->{'date'} = strip_whitespace($1); 
     888    } 
     889    elsif ($str =~ /Country: (.+)/) 
     890    { 
     891      $show->{'country'} = [[ split(/, /, strip_whitespace($1)) ]]; 
     892    } 
     893    elsif ($str =~ /Language: (.+)/) 
     894    { 
     895      $show->{'language'} = [ strip_whitespace($1) ]; 
    853896    } 
    854897    elsif ($str =~ /Other:(.+)/) 
     
    856899      next unless (strip_whitespace($1)); 
    857900      $str = $tag->as_HTML(); 
    858       @extra = split(/<br \/>/, $tag->as_HTML()); 
     901      @extra = split(/<br ?\/?>/, $tag->as_HTML()); 
    859902      my (@to_add, %video); 
    860903      foreach my $bit (@extra) 
     
    866909        { 
    867910            $show->{'previously-shown'} = { }; 
    868             next;   # Don't need this in the desc as well as it's 
    869                     # highlighted by MythTV 
    870911        } 
    871912        elsif ($bit eq 'Widescreen') 
     
    876917        { 
    877918            $show->{'subtitles'} = [ { 'type' => 'teletext' } ]; 
    878             next;   # Just clutters up the desc 
    879919        } 
    880         elsif ($bit eq 'Premiere') 
     920        elsif ($bit eq 'Premiere' || $bit eq 'New Episode') 
    881921        { 
    882922            $show->{'premiere'} = [ $bit ]; 
     
    888928        push (@to_add, $bit); 
    889929        $show->{'video'} = \%video if (%video); 
    890       } 
    891       foreach (@to_add) 
    892       { 
    893         if ($show->{'desc'}) 
    894         { 
    895           $show->{'desc'}[0][0] .= " $_."; 
    896         } 
    897         else 
    898         { 
    899           $show->{'desc'} = [[ "$_.", $lang ]]; 
    900         } 
    901930      } 
    902931    } 
  • trunk/grabbers/southerncross_website

    r832 r943  
    3434 
    3535my $progname = "southerncross_website"; 
    36 my $version = "0.14"; 
     36my $version = "0.15"; 
    3737 
    3838#use LWP::UserAgent; 
     
    682682        $post_desc .= $text; 
    683683        if ($rating) { 
    684           $rating .= " " . subrating($text); 
     684          $rating .= " " . &Shepherd::Common::subrating($text); 
    685685        } else { 
    686           $rating = subrating($text); 
     686          $rating = &Shepherd::Common::subrating($text); 
    687687        } 
    688688        &log("parse_page debug: verbose rating : $text") if $opt->{debug}; 
     
    761761  return @categories; 
    762762} 
    763  
    764 # (Adult Themes) 
    765 # (Some Violence, Adult Themes, Supernatural Themes) 
    766 # (Drug References, Adult Themes) 
    767 # (Very Coarse Language, Sexual References, Drug References, Adult Themes, Nudity) 
    768 # (Some Violence) 
    769 # (Drug Use, Strong Adult Themes) 
    770 # (Some Violence, Adult Themes) 
    771 # (Some Coarse Language) 
    772 # (Sexual References) 
    773 # (Mild Coarse Language, Sexual References) 
    774 # (Sex Scenes, Adult Themes, Supernatural Themes) 
    775 ## (Qualifying - Sat) 
    776 sub subrating 
    777 { 
    778   my $string = shift; 
    779   my @subrating; 
    780  
    781   push(@subrating, "v") if $string =~ /Violence/i; 
    782   push(@subrating, "l") if $string =~ /Language/i; 
    783   push(@subrating, "s") if $string =~ /Sex/i; 
    784   push(@subrating, "d") if $string =~ /Drug/i; 
    785   push(@subrating, "a") if $string =~ /Adult/i; 
    786   push(@subrating, "n") if $string =~ /Nudity/i; 
    787   push(@subrating, "h") if $string =~ /Supernatural/i; 
    788  
    789   return join(",",@subrating); 
    790 } 
  • trunk/references/Shepherd/Common.pm

    r936 r943  
    33# Shepherd::Common library 
    44 
    5 my $version = '0.27'; 
     5my $version = '0.28'; 
    66 
    77# 
     
    770770########################################################################## 
    771771 
     772# (Adult Themes) 
     773# (Some Violence, Adult Themes, Supernatural Themes) 
     774# (Drug References, Adult Themes) 
     775# (Very Coarse Language, Sexual References, Drug References, Adult Themes, Nudity) 
     776# (Some Violence) 
     777# (Drug Use, Strong Adult Themes) 
     778# (Some Violence, Adult Themes) 
     779# (Some Coarse Language) 
     780# (Sexual References) 
     781# (Mild Coarse Language, Sexual References) 
     782# (Sex Scenes, Adult Themes, Supernatural Themes) 
     783## (Qualifying - Sat) 
     784sub subrating 
     785{ 
     786  my $string = shift; 
     787  my @subrating; 
     788 
     789  push(@subrating, "v") if $string =~ /Violence/i; 
     790  push(@subrating, "l") if $string =~ /Language/i; 
     791  push(@subrating, "s") if $string =~ /Sex/i; 
     792  push(@subrating, "d") if $string =~ /Drug/i; 
     793  push(@subrating, "a") if $string =~ /Adult/i; 
     794  push(@subrating, "n") if $string =~ /Nudity/i; 
     795  push(@subrating, "h") if $string =~ /Horror|Supernatural/i; 
     796 
     797  return join(",",@subrating); 
     798} 
     799 
     800########################################################################## 
     801 
    772802sub log 
    773803{ 
  • trunk/status

    r942 r943  
    11application     shepherd            1.2.24 
    22reference       channel_list        6 
    3 reference       Shepherd/Common.pm  0.27 
     3reference       Shepherd/Common.pm  0.28 
    44reference       Shepherd/MythTV.pm  0.6 
    55grabber         yahoo7widget        1.92 
    6 grabber         rex                 3.5.10 
     6grabber         rex                 3.6.0 
    77grabber         abc_website         3.14 
    88grabber         sbsnews_website     0.18 
     
    1212grabber         foxtel_swf          0.24 
    1313grabber         channelnsw_gov      0.8 
    14 grabber         southerncross_website   0.14 
     14grabber         southerncross_website   0.15 
    1515grabber         ten_website         1.04 
    1616grabber         selectv_website     0.02