Changeset 950

Show
Ignore:
Timestamp:
10/17/07 23:51:41 (6 years ago)
Author:
max
Message:

update branch: svn merge -r 941:949 http://svn.whuffy.com/shepherd/trunk .

Location:
branches/predictive
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • branches/predictive/applications/shepherd

    r932 r950  
    22 
    33my $progname = 'shepherd'; 
    4 my $version = '1.2.24'; 
     4my $version = '2.0.0'; 
    55 
    66# tv_grab_au 
     
    13661366    $display_output = 1 if (!defined $display_output); 
    13671367    $progtype = $components->{$component}->{type} unless ($progtype); 
     1368    if ($components->{$component}->{default_cmdline}) 
     1369    { 
     1370        my $parameters = $components->{$component}->{default_cmdline}; 
     1371        $parameters =~ s/:/ /g; 
     1372        $prog .= " $parameters"; 
     1373    } 
    13681374 
    13691375    my $prog_output = ""; 
     
    18171823    my $arg = join(":",@args); 
    18181824 
    1819     if ($component eq $progname) { 
    1820         if ((!defined $arg) || ($arg eq "")) { 
    1821             delete $components->{$progname}->{default_cmdline}; 
    1822             &log("\ncleared default options for $progname\n"); 
    1823         } else { 
    1824             $components->{$progname}->{default_cmdline} = "--".join(":--",@args); 
    1825             &log("\nset default options for $progname to: ".$components->{$progname}->{default_cmdline}."\n"); 
    1826         } 
    1827         write_config_file(); 
    1828         return; 
    1829     } 
    1830  
    18311825    if ((!defined $arg) || ($arg eq "")) { 
    1832         &log("\nNothing to set: you need to use this as --component-set (component):(settings)\n"); 
    1833         return; 
    1834     } 
    1835  
    1836     my $opt_set = query_config($component, 'option_set'); 
    1837     if (!defined $opt_set) { 
    1838         &log("\nComponent $component does not have any tunable parameters.\n"); 
    1839         return; 
    1840     } 
    1841  
    1842     my ($result,$resultmsg,$test_output) = call_prog($component,query_filename($component,$components->{$component}->{type})." $opt_set $arg"." 2>&1",1,1,1); 
     1826        delete $components->{$component}->{default_cmdline}; 
     1827        &log("\nCleared default options for $component.\n"); 
     1828    } else { 
     1829        $components->{$component}->{default_cmdline} = "--".join(":--",@args); 
     1830        &log("\nSet default options for $component to: --".join(" --",@args)."\n"); 
     1831    } 
     1832    &write_config_file; 
    18431833} 
    18441834 
     
    41464136 
    41474137    # explicitly track unparsable dates, excessive durations, etc 
    4148     foreach ( qw( programmes total_duration progs_with_invalid_date progs_too_long progs_too_short progs_with_unknown channel progs_outside_window progs_optional )) 
     4138    foreach ( qw( programmes total_duration progs_with_invalid_date progs_too_long progs_too_short progs_with_unknown channel progs_outside_window progs_optional progs_tba)) 
    41494139    { 
    41504140        $this_plugin->{$_} = 0; 
     
    42124202            } 
    42134203 
     4204            # Don't count shows that are simply 'To Be Advised' 
     4205            # These will be dropped by the reconciler 
     4206            if ($prog->{title}->[0]->[0] =~ /^to be advised$/i 
     4207                    or 
     4208                $prog->{title}->[0]->[0] =~ /^tba$/i) 
     4209            { 
     4210                $this_plugin->{progs_tba}++; 
     4211                next; 
     4212            } 
     4213 
    42144214            # store plugin-specific stats 
    42154215            $this_plugin->{programmes}++; 
     
    42234223            # only analyze / check against policy if its a non optional channel 
    42244224            if (defined $channels->{$ch}) { 
    4225                 # store channel-specific stats 
    4226                 $channel_data->{$ch}->{programmes}++; 
    4227                 $channel_data->{$ch}->{total_duration} += $this_duration; 
    42284225 
    42294226                # programme is outside the timeslots we are interested in. 
     
    42334230                    next; 
    42344231                } 
     4232 
     4233                # store channel-specific stats 
     4234                $channel_data->{$ch}->{programmes}++; 
     4235                $channel_data->{$ch}->{total_duration} += $this_duration; 
    42354236 
    42364237                # store timeslot info 
  • branches/predictive/grabbers/abc_website.conf

    r790 r950  
    66            'regions' => '', 
    77            'option_ready' => '--version', 
    8             'option_set' => '--set', 
    98            'desc' => 'guide data for ABC only from http://www.abc.net.au/tv/guide/netw/', 
    109            'max_days' => '14', 
  • branches/predictive/grabbers/acctv_website

    r937 r950  
    2323my %stats; 
    2424my $o; 
    25 Shepherd::Common::program_begin(\$o, "acctv_website", "0.02", \%stats); 
     25Shepherd::Common::program_begin(\$o, "acctv_website", "0.03", \%stats); 
    2626 
    2727my ($channels, $opt_channels, $gaps) = Shepherd::Common::read_channels($o, ("ACC")); 
     
    232232                        $prog->{$_} = $details_cache->{$cache_key}->{$_}; 
    233233                } 
    234                 if (defined $prog->{length}) { 
    235                         $prog->{stop} = $prog->{start} + $prog->{length}; 
    236                         delete $prog->{length}; 
    237                 } 
     234                $prog->{stop} = $prog->{start} + $prog->{length} if (defined $prog->{length}); 
    238235                $stats{cached_used}++; 
    239236                return $prog; 
     
    289286                if ($header eq 'Length') { 
    290287                        if ($content !~ /^(\d+) /) { # length 
    291                                 Shepherd::Common::log("skipped detail length : " . $td->as_HTML()) if $o->{debug}; 
     288                                Shepherd::Common::log("skipped detail length : " . $td->as_HTML()); 
    292289                                $td = shift @tds || last; 
    293290                                $header = $td->as_trimmed_text(); 
     291                                $header =~ s/[^\x20-\x7f\x0a]//g; # remove   
    294292                                next; 
    295293                        } 
    296294                        my $length = ($1 < 3 ? ($1*60*60) : ($1*60)); 
    297295                        $prog->{length} = $length; 
     296                        $prog->{stop} = $prog->{start} + $length; 
    298297                        Shepherd::Common::log("set length     : $length") if ($o->{debug}); 
    299298                } elsif ($header eq 'Genre') { 
     
    328327        } 
    329328 
    330         if (defined $prog->{length}) { 
    331                 $prog->{stop} = $prog->{start} + $prog->{length}; 
    332                 delete $prog->{length}; 
    333         } 
    334  
    335329        return $prog; 
    336330} 
  • branches/predictive/grabbers/citysearch

    r934 r950  
    44# 
    55 
    6 my $version = '2.0.2'; 
     6my $version = '2.0.3'; 
    77 
    88use strict; 
     
    336336 
    337337    $div = $tree->look_down(_tag => 'div', class => 'contentDetails'); 
    338     my %video; 
     338    my (%video, $category, %type); 
    339339    foreach my $tr ($div->look_down(_tag => 'tr')) 
    340340    { 
     
    343343            if ($1 eq 'Type') 
    344344            { 
    345                 push (@{$show->{category}}, $2) unless ($2 eq 'N/A'); 
     345                $category = &strip_whitespace($2); 
    346346            } 
    347347            elsif ($1 eq 'Country') 
     
    349349                $show->{country} = $2; 
    350350            } 
     351            elsif ($1 eq 'Language') 
     352            { 
     353                $show->{language} = $2; 
     354            } 
    351355            elsif ($1 eq 'Cast') 
    352356            { 
     
    356360                } 
    357361            } 
     362            elsif ($1 eq 'Director') 
     363            { 
     364                foreach (split /, /, $2) 
     365                { 
     366                    push @{$show->{credits}{director}}, &strip_whitespace($_); 
     367                } 
     368            } 
     369            elsif ($1 eq 'Writer') # unseen 
     370            { 
     371                foreach (split /, /, $2) 
     372                { 
     373                    push @{$show->{credits}{writer}}, &strip_whitespace($_); 
     374                } 
     375            } 
    358376            elsif ($1 eq 'Duration') 
    359377            { 
    360                 if (!$show->{stop} and $2 =~ /(\d+) minutes/) 
    361                 { 
    362                     $show->{stop} = $show->{start} + ($1 * 60); 
    363                     &log("Filled in stop time! $1 minutes.") if ($debug); 
     378                if ($2 =~ /(\d+) min/) 
     379                { 
     380                    $show->{length} = $1 * 60; 
     381                    if (!$show->{stop}) { 
     382                        $show->{stop} = $show->{start} + ($1 * 60); 
     383                        &log("Filled in stop time! $1 minutes.") if ($debug); 
     384                    } 
    364385                } 
    365386            } 
     
    388409                    { 
    389410                        $show->{'premiere'} = [ $info ]; 
     411                        $type{premiere} = 1; 
    390412                    } 
    391413                    elsif ($info eq 'Live') 
    392414                    { 
    393                         push @{$show->{category}}, $info; 
     415                        $type{live} = 1; 
     416                    } 
     417                    elsif ($info eq 'Final' || $info eq 'Finale') # unseen 
     418                    { 
     419                        $type{final} = 1; 
     420                    } 
     421                    elsif ($info eq 'Return') # unseen 
     422                    { 
     423                        $type{return} = 1; 
    394424                    } 
    395425                    elsif ($info eq 'Repeat') 
     
    399429                    elsif ($info eq 'Movie') 
    400430                    { 
    401                         push @{$show->{category}}, 'movie'; 
     431                        $type{movie} = 1; 
    402432                    } 
    403433                    else 
     
    430460    } 
    431461    $show->{video} = { %video } if (%video); 
     462    $show->{category} = [ &Shepherd::Common::generate_category( 
     463        $show->{title}, $category, %type) ]; 
    432464 
    433465    $tree->delete; 
     
    489521                $p{$field} = [[ $p{$field}, $lang ]] if ($p{$field}); 
    490522            } 
     523            $p{language} = [ $p{language}, $lang ] if ($p{language}); 
    491524            $p{start} = &POSIX::strftime("%Y%m%d%H%M", localtime($p{start})); 
    492525            $p{stop} = &POSIX::strftime("%Y%m%d%H%M", localtime($p{stop})); 
    493526            $p{rating} = [[ $p{rating}, 'ABA', undef ]] if ($p{rating}); 
    494             if ($p{category}) 
     527            if ($p{category} && ref($p{category}) eq "ARRAY" 
     528                    && $p{category}[0] && ref($p{category}[0]) ne "ARRAY") # obsolete 14/10/2007 
    495529            { 
    496530                foreach (@{$p{category}}) 
  • branches/predictive/grabbers/oztivo

    r900 r950  
    33# OzTivo grabber 
    44 
    5 my $version = '1.13'; 
     5my $version = '1.14'; 
    66 
    77# Requires configuration! 
     
    440440    my $l_min = int($local_tz / 100) * 60 + $local_tz % 100 % 60;  
    441441    my $s_min = int($sydney_tz / 100) * 60 + $sydney_tz % 100 % 60;  
    442     my $tz_diff = int(($l_min - $s_min) / 60) * 100 + (($l_min - $s_min) % 60); 
     442    # can't use %60 because it always returns a positive number 
     443    my $tz_diff = int(($l_min - $s_min) / 60) * 100 + (($l_min - $s_min) - (int(($l_min - $s_min)/60)*60)); 
    443444 
    444445    # Are we in DST? 
     
    493494 
    494495    # Check Sydney's DST status each day for 7 days 
    495     for (my $day = 0; $day < 7; $day++) 
     496    for (my $day = 0; $day < 8; $day++) 
    496497    { 
    497498        my $t = $start + ($day * 24*60*60); 
  • branches/predictive/grabbers/rex

    r888 r950  
    33# "Rex" 
    44 
    5 my $version  = '3.5.9'; 
     5my $version  = '3.6.2'; 
    66 
    77# An Australian TV Guide Grabber (a.k.a. tv_grab_au) 
     
    9090# 3.5.7   : Bugfix : parse "rest of day" guide page correctly 
    9191# 3.5.8   : Bugfix : don't die on failed cache write 
     92# 3.5.9   : Code change: use Shepherd::Common::read/write cache 
     93# 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 
     98# 3.6.1   : Feature: don't split category, still add 'sport' and 'movie', 
     99#                    support 'LIVE' by appending to beginning of category, 
     100#                    use Shepherd::Common::translate_category 
     101# 3.6.2   : Feature: use new Common::generate_category, don't add 'advisory', 
     102#                    add 'length', add 'final' and 'return' (unseen) 
    92103 
    93104use strict; 
     
    210221print stats(1); 
    211222 
     223Shepherd::Common::print_stats($progname, $version, $runtime, %stats); 
     224 
    212225exit 0; 
    213226 
     
    240253      # Special bandwidth-saving URL for day 0 
    241254 
    242       $guidedata = get_page($DATASOURCE_GUIDE_TODAY); 
     255      my $cacheid = $DATASOURCE_GUIDE_TODAY; 
     256      if ($cached->{$cacheid}) { 
     257        $guidedata = $cached->{$cacheid}->{data}; 
     258      } else { 
     259        $guidedata = get_page($DATASOURCE_GUIDE_TODAY); 
     260        if ($guidedata) { 
     261          $cached->{$cacheid}->{data} = $guidedata; 
     262          $cached->{$cacheid}->{stop} = POSIX::strftime("%Y%m%d%H%M%S", localtime($runtime)); 
     263          $cached->{$cacheid}->{title}[0][0] = $cacheid; 
     264        } 
     265      } 
    243266      parse_guide($guidedata, $date) if ($guidedata); 
    244267    } 
     
    249272      for (1 .. 4) 
    250273      { 
    251         $guidedata = get_page(url => $DATASOURCE_GUIDE, 
    252                         postvars =>  
    253                         [ 'action' => "sessionTimes", 
    254                           'region_id' => $rid, 
    255                           'date' => $date, 
    256                           'period' => $_, 
    257                           'submit' => 'submit' 
    258                         ]); 
    259         parse_guide($guidedata, $date, $_) if ($guidedata); 
     274        my $cacheid = "${DATASOURCE_GUIDE}?r=${rid}&d=${date}&p=$_"; 
     275        if ($cached->{$cacheid}) { 
     276          $guidedata = $cached->{$cacheid}->{data}; 
     277        } else { 
     278          $guidedata = get_page(url => $DATASOURCE_GUIDE, 
     279                        postvars => 
     280                        [ 'action' => "sessionTimes", 
     281                          'region_id' => $rid, 
     282                          'date' => $date, 
     283                          'period' => $_, 
     284                          'submit' => 'submit' 
     285                        ]); 
     286          if ($guidedata) { 
     287            $cached->{$cacheid}->{data} = $guidedata; 
     288            $cached->{$cacheid}->{stop} = POSIX::strftime("%Y%m%d%H%M%S", localtime($runtime)); 
     289            $cached->{$cacheid}->{title}[0][0] = $cacheid; 
     290          } 
     291        } 
     292        parse_guide($guidedata, $date, $_) if ($guidedata); 
    260293      } 
    261294    } 
     
    511544sub clean_cache 
    512545{ 
    513     my $r = expand_date(localtime(time() - 3600).""); 
     546    my $r = expand_date(localtime(time() - 3*3600).""); 
    514547    my $c = 0; 
    515548    print "Removing cache items that finish earlier than $r.\n" if ($debug); 
     
    799832    $block = $block->right(); 
    800833  } 
     834  my ($category, %type); 
    801835  foreach my $tag ($block->look_down('_tag' => 'tr')) 
    802836  { 
     
    804838    if ($str =~ /Genre:(.+)/) 
    805839    { 
     840      $category = strip_whitespace($1); 
     841      $str = $tree->find('h5'); 
     842      $type{movie} = 1 if ($str and $str->as_text() =~ /movie/i); 
     843    } 
     844    elsif ($str =~ /Rating:(.+)/) 
     845    { 
    806846      $str = strip_whitespace($1); 
    807       if ($str eq 'N/A') 
    808       { 
    809         @extra = ( $str ); 
     847      $str =~ /(.*?)\s*\[(.+)\]/; 
     848      $str = $1; 
     849      my $sr = $2; 
     850      if ($sr) { 
     851        $sr =~ s/or medical procedures//ig; 
     852        $sr = &Shepherd::Common::subrating($sr); 
    810853      } 
    811       else 
    812       { 
    813         @extra = split(/\//, $str); 
    814       } 
    815       $str = $tree->find('h5'); 
    816       if ($str and $str->as_text() =~ /movie/i) 
    817       { 
    818         unshift (@extra, 'movie'); 
    819       } 
    820  
    821       foreach (@extra) 
    822       { 
    823         $_ = [ translate_category($_), $lang ]; 
    824       } 
    825       $show->{'category'} = [ @extra ]; 
    826     } 
    827     elsif ($str =~ /Rating:(.+)/) 
    828     { 
    829       $str = strip_whitespace($1); 
    830       if ($str =~ /(.*?)\s*\[(.+)\]/) 
    831       { 
    832         @extra = split(/, /, $2); 
    833         foreach (@extra) 
    834         { 
    835           $_ = [ $_, 'advisory', undef ]; 
    836         } 
    837         $show->{'rating'} = [[ $1, 'ABA', undef],  @extra ]; 
    838       } 
    839       else 
    840       { 
    841         $show->{'rating'} = [[ $1, "ABA", undef]]; 
    842       } 
     854      $show->{'rating'} = [[ $sr ? "$str $sr" : $str, 'ABA', undef]]; 
    843855    } 
    844856    elsif ($str =~ /Cast: (.+)/) 
     
    846858      $show->{'credits'}{'actor'} = [ split(/, /, strip_whitespace($1)) ]; 
    847859    } 
     860    elsif ($str =~ /Director: (.+)/) 
     861    { 
     862      $show->{'credits'}{'director'} = [ split(/, /, strip_whitespace($1)) ]; 
     863    } 
     864    elsif ($str =~ /Writer: (.+)/) # unseen 
     865    { 
     866      $show->{'credits'}{'writer'} = [ split(/, /, strip_whitespace($1)) ]; 
     867    } 
    848868    elsif ($str =~ /Year:\s*(\d+)/) 
    849869    { 
    850870      $show->{'date'} = strip_whitespace($1); 
     871    } 
     872    elsif ($str =~ /Country: (.+)/) 
     873    { 
     874      $show->{'country'} = [[ split(/, /, strip_whitespace($1)) ]]; 
     875    } 
     876    elsif ($str =~ /Language: (.+)/) 
     877    { 
     878      $show->{'language'} = [ strip_whitespace($1) ]; 
     879    } 
     880    elsif ($str =~ /Duration:\s(\d+)/) 
     881    { 
     882      $show->{'length'} = $1 * 60; 
    851883    } 
    852884    elsif ($str =~ /Other:(.+)/) 
     
    854886      next unless (strip_whitespace($1)); 
    855887      $str = $tag->as_HTML(); 
    856       @extra = split(/<br \/>/, $tag->as_HTML()); 
    857       my (@to_add, %video); 
     888      @extra = split(/<br ?\/?>/, $tag->as_HTML()); 
     889      my %video; 
    858890      foreach my $bit (@extra) 
    859891      { 
     
    864896        { 
    865897            $show->{'previously-shown'} = { }; 
    866             next;   # Don't need this in the desc as well as it's 
    867                     # highlighted by MythTV 
    868898        } 
    869899        elsif ($bit eq 'Widescreen') 
     
    871901            $video{'aspect'} = '16:9'; 
    872902        } 
     903        elsif ($bit eq 'High Definition') 
     904        { 
     905            $video{'quality'} = 'HDTV'; 
     906        } 
    873907        elsif ($bit eq 'Closed Captions') 
    874908        { 
    875909            $show->{'subtitles'} = [ { 'type' => 'teletext' } ]; 
    876             next;   # Just clutters up the desc 
     910        } 
     911        elsif ($bit eq 'New Episode') 
     912        { 
     913            $show->{'premiere'} = [ $bit ]; 
    877914        } 
    878915        elsif ($bit eq 'Premiere') 
    879916        { 
    880917            $show->{'premiere'} = [ $bit ]; 
    881         } 
    882         elsif ($bit eq 'High Definition') 
    883         { 
    884             $video{'quality'} = 'HDTV'; 
    885         } 
    886         push (@to_add, $bit); 
     918            $type{premiere} = 1; 
     919        } 
     920        elsif ($bit eq 'LIVE' || $bit eq 'Live') 
     921        { 
     922            $type{live} = 1; 
     923        } 
     924        elsif ($bit eq 'Final' || $bit eq 'Finale') 
     925        { 
     926            $type{final} = 1; 
     927        } 
     928        elsif ($bit eq 'Return') # unseen 
     929        { 
     930            $type{return} = 1; 
     931        } 
    887932        $show->{'video'} = \%video if (%video); 
    888933      } 
    889       foreach (@to_add) 
    890       { 
    891         if ($show->{'desc'}) 
    892         { 
    893           $show->{'desc'}[0][0] .= " $_."; 
    894         } 
    895         else 
    896         { 
    897           $show->{'desc'} = [[ "$_.", $lang ]]; 
    898         } 
    899       } 
    900     } 
    901   } 
     934    } 
     935  } 
     936  $show->{'category'} = [ &Shepherd::Common::generate_category( 
     937      $show->{'title'}[0][0], $category, %type) ]; 
    902938 
    903939  $tree->delete(); 
     
    919955  } 
    920956  return 0; 
    921 } 
    922  
    923 sub translate_category 
    924 { 
    925   my %translation = (   'Sport' => 'sports', 
    926                         'Soap Opera' => 'Soap', 
    927                         'Science and Technology' => 'Science/Nature', 
    928                         'Real Life' => 'Reality', 
    929                         'Cartoon' => 'Animation', 
    930                         'Family' => 'Children', 
    931                         'Murder' => 'Crime' ); 
    932                          
    933   return $translation{$_} if $translation{$_}; 
    934   return $_; 
    935957} 
    936958 
     
    10351057  if (@ARGV) 
    10361058  { 
    1037     print "\nERROR: Unknown option(s): @ARGV\n"; 
    1038     help(); 
     1059    print "\nWARNING: Ignoring unknown option(s): @ARGV\n\n"; 
    10391060  } 
    10401061} 
  • branches/predictive/grabbers/southerncross_website

    r832 r950  
    3434 
    3535my $progname = "southerncross_website"; 
    36 my $version = "0.14"; 
     36my $version = "0.16"; 
    3737 
    3838#use LWP::UserAgent; 
     
    599599    # <b>Sunday Afternoon Premiere Movie</b> - Rat 
    600600    # <b>Sunday Afternoon Movie</b> - Evolution 
    601     my ($rating, $movie, $premiere, $final, $return, $series, $live); 
     601    my ($rating, %type); 
    602602    my $post_desc=""; 
    603603    if ($subtitle and $title =~ /^(Friday|Saturday|Sunday) .* Movie$/i) { 
    604       $movie = 1; 
    605       $premiere = 1 if ($title =~ /Premiere/i); 
     604      $type{movie} = 1; 
     605      $type{premiere} = 1 if ($title =~ /Premiere/i); 
    606606      &log("parse_page debug: Changing title $title to $subtitle")  
    607607          if $opt->{debug}; 
     
    616616    # (Series Final) 
    617617    # (Series Return) 
     618    # (Replay) 
    618619    ## (New Time) 
    619620    ## (Qualifying) 
     621    ## (Special Presentation) 
    620622    # $subtitle =~ , live from Aurora 
    621623    if ($title =~ s/(\((.*)\))//) { 
    622624        $post_desc .= $1; 
    623625        my $tag = $2; 
    624         $series = 1 if ($tag =~ /(^| )Series( |$)/i); 
    625         $premiere = 1 if ($tag =~ /(^| )Premiere( |$)/i); 
    626         $final = 1 if ($tag =~ /(^| )Finale?( |$)/i); 
    627         $return = 1 if ($tag =~ /(^| )Return( |$)/i); 
    628     } 
    629     $live = 1 if ($subtitle and $subtitle =~ /live from/i); 
     626        $type{series} = 1 if ($tag =~ /(^|\W)Series(\W|$)/i); 
     627        $type{premiere} = 1 if ($tag =~ /(^|\W)Premiere(\W|$)/i); 
     628        $type{final} = 1 if ($tag =~ /(^|\W)Finale?(\W|$)/i); 
     629        $type{return} = 1 if ($tag =~ /(^|\W)Return(\W|$)/i); 
     630        $type{repeat} = 1 if ($tag =~ /(^|\W)Repeat(\W|$)/i); # unseen 
     631        $type{repeat} = 1 if ($tag =~ /(^|\W)Replay(\W|$)/i); 
     632    } 
     633    $type{live} = 1 if ($subtitle and $subtitle =~ /live from/i); 
    630634    $prog->{title} = [[$title, $opt->{lang}]]; 
    631635    &log("parse_page debug: title     : $title $post_desc") if ($opt->{debug}); 
     
    649653 
    650654      if ($text) { 
     655        # - Live from Aurora  
    651656        # Hosted by Mike Goldman & Bree Amer, this ... # how to parse all 
    652657        # Hosted by Mike Goldman, Ryan Fitzgerald and Bree Amer. 
    653658        # ^Guest Stars: Mel Gibson Studio ... # how to parse all 
     659        # Guests include: Damien Leith, Young Divas and Darren Hayes. 
    654660        # Starring: $ 
    655661        ## Insert Cast: Damon Wayans, Adam Sandler, Kristen Wilson, James Caan, 
    656662        ## James Farentino (Cons Adv: Some Coarse Language, Some Violence, Sexual References) 
    657         # - Live from Aurora  
    658663        ## Featuring cartoons: Yu Gi Oh! Gx (Final), All Grown Up (Repeat), 
    659664        ## Teenage Mutant Ninja Turtules (repeat) 
     665        $type{live} = 1 if ($text =~ /Live from/i); 
    660666        my $cast = ""; 
    661         $cast .= "$1, " if ($text =~ /Hosted by (\w+ \w+)( |\.|,|$)/i); 
    662         $cast .= "$1, " if ($text =~ /Guest Stars: (\w+ \w+)( |\.|,|$)/i); 
    663         $cast .= $1 if ($text =~ /Starring: (.+)$/i); 
    664         $prog->{'credits'}{'actor'} = [ split(/, /, $cast) ] if ($cast); 
    665         $live = 1 if ($text =~ /Live from/i); 
     667        $cast .= "$1," if ($text =~ /Hosted by (\w+ \w+)( |\.|,|$)/i); 
     668        $cast .= "$1," if ($text =~ /Guest Stars: (\w+ \w+)( |\.|,|$)/i); 
     669        $cast .= "$1," if ($text =~ /Guests Include: (.+?)\./i); 
     670        $cast .= $1 if ($text =~ s/Starring: (.+)$//i); 
     671        $prog->{'credits'}{'actor'} = [ split(/,|&amp;|&|\Wand\W/i, $cast) ] if $cast; 
    666672        $prog->{desc} = [[$text, $opt->{lang}]]; # desc 
    667673        &log("parse_page debug: desc      : $text") if $opt->{debug}; 
     
    682688        $post_desc .= $text; 
    683689        if ($rating) { 
    684           $rating .= " " . subrating($text); 
     690          $rating .= " " . &Shepherd::Common::subrating($text); 
    685691        } else { 
    686           $rating = subrating($text); 
     692          $rating = &Shepherd::Common::subrating($text); 
    687693        } 
    688694        &log("parse_page debug: verbose rating : $text") if $opt->{debug}; 
     
    696702    } 
    697703  PART: 
    698     my @categories; 
    699     my $cft = category_from_title($title); 
    700     push(@categories, [$cft, $opt->{lang}]) if $cft; 
    701     push(@categories, ["Children", $opt->{lang}]) 
    702         if $rating and $rating =~ /^(C|P)$/i; 
    703     push(@categories, ["movie", $opt->{lang}]) if $movie; 
    704     push(@categories, ["series", $opt->{lang}]) if $series; 
    705     @categories = prepend_category("Live", @categories) if $live; 
    706     @categories = prepend_category("Premiere", @categories) if $premiere; 
    707     @categories = prepend_category("Return", @categories) if $return; 
    708     @categories = prepend_category("Final", @categories) if $final; 
    709     $prog->{'category'} = [@categories] if @categories; 
    710     $prog->{'premiere'} = ['premiere', $opt->{lang}] if $premiere; 
    711     $prog->{'last-chance'} = ['final', $opt->{lang}] if $final; 
    712     #$prog->{'previously-shown'} = { } if $repeat; # can't detect 
     704    my $category = category_from_title($title); 
     705    $category = "Children" if !$category && $rating && $rating =~ /^(C|P)$/i; 
     706    $prog->{'category'} = [ &Shepherd::Common::generate_category( 
     707        $title, $category, %type) ]; 
     708    $prog->{'premiere'} = ['premiere', $opt->{lang}] if $type{premiere}; 
     709    $prog->{'last-chance'} = ['final', $opt->{lang}] if $type{final}; 
     710    $prog->{'previously-shown'} = { } if $type{repeat}; 
    713711    $prog->{rating}  = [[$rating, "ABA", undef]] if $rating; 
    714     if ($post_desc) { 
    715       if (not $prog->{desc}) { 
    716         $prog->{desc} = [[$post_desc, $opt->{lang}]]; 
    717       } else { 
    718         $prog->{desc}->[0]->[0] .= "\n" . $post_desc; 
    719       } 
    720     } 
     712#     if ($post_desc) { 
     713#       if (not $prog->{desc}) { 
     714#         $prog->{desc} = [[$post_desc, $opt->{lang}]]; 
     715#       } else { 
     716#         $prog->{desc}->[0]->[0] .= "\n" . $post_desc; 
     717#       } 
     718#     } 
    721719 
    722720    $progs->{$prog->{start}} = $prog; 
     
    737735{ 
    738736  my $title = shift; 
    739   return "News" if $title=~/(^| )News( |$)/i; 
    740   return "sports" if $title=~/(^| )Sports Tonight( |$)/i; 
    741   return "sports" if $title=~/(^| )AFL( |$)/i; 
    742   return "Infotainment" if $title=~/(^| )Infomercials?( |$)/i; 
    743   return "Reality" if $title=~/(^| )Big Brother( |$)/i; 
    744   return "Animation" if $title=~/(^| )The( All New)? Simpsons( |$)/i; 
    745   return "Music" if $title=~/(^| )Video Hits( |$)/i; 
    746 } 
    747  
    748 sub prepend_category 
    749 { 
    750   my ($item, @categories) = @_; 
    751  
    752   if (@categories > 0 and $categories[0][0]) { 
    753     if ($categories[0][0] eq "movie") { unshift(@categories, ["Movie", $opt->{lang}]) } 
    754     elsif ($categories[0][0] eq "sports") { unshift(@categories, ["Sports", $opt->{lang}]) } 
    755     elsif ($categories[0][0] eq "series") { unshift(@categories, ["Series", $opt->{lang}]) } 
    756     elsif ($categories[0][0] eq "tvshow") { unshift(@categories, ["TVShow", $opt->{lang}]) } 
    757     $categories[0][0] = $item . " " . $categories[0][0]; 
    758   } else { 
    759     push(@categories, [$item, $opt->{lang}]); 
    760   } 
    761   return @categories; 
    762 } 
    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 } 
     737  return "News" if $title=~/(^|\W)News(\W|$)/i; 
     738  return "sports" if $title=~/(^|\W)Sports Tonight(\W|$)/i; 
     739  return "sports" if $title=~/(^|\W)AFL(\W|$)/i; 
     740  return "Infotainment" if $title=~/(^|\W)Infomercials?(\W|$)/i; 
     741  return "Reality" if $title=~/(^|\W)Big Brother(\W|$)/i; 
     742  return "Animation" if $title=~/(^|\W)The( All New)? Simpsons(\W|$)/i; 
     743  return "Music" if $title=~/(^|\W)Video Hits(\W|$)/i; 
     744  return "Soap" if $title=~/(^|\W)The Bold (&amp;|&|and) The Beautiful(\W|$)/i; 
     745  return "Lifestyle/Cooking, Food & Wine" if $title=~/(^|\W)Hueys Cooking Adventures(\W|$)/i; 
     746  return "Variety" if $title=~/(^|\W)The Late Show With David Letterman(\W|$)/i; 
     747} 
  • branches/predictive/grabbers/yahoo7widget

    r866 r950  
    2222 
    2323my $progname = "yahoo7widget"; 
    24 my $version = "1.92"; 
     24my $version = "1.93"; 
    2525 
    2626use XMLTV; 
     
    512512                        foreach my $field ('title', 'subtitle', 'description_1', 'main_cast', 'year_released', 'rating', 
    513513                          'genre', 'running_time', 'repeat', 'country', 'movie', 'premiere', 'final', 'captions', 'warnings',  
    514                           'color', 'language', 'director', 'live') { 
     514                          'color', 'language', 'director', 'live', 'return') { 
    515515                                eval { $e{$field} = $event->getElementsByTagName("$field")->item(0)->getFirstChild->getNodeValue; }; 
    516516                        } 
    517517                        # other fields we dont pick up but exist in source xml data include: 
    518518                        #  other_title, description_2, genre_id, highlight, ext_url, y7_url 
    519  
    520                         my @categories; 
    521  
    522                         push(@categories, [ "movie",$opt->{lang} ] ) if (($e{movie}) && ($e{movie} == 1)); 
    523                         push(@categories, [ "final",$opt->{lang} ] ) if (($e{final}) && ($e{final} == 1)); 
    524                         push(@categories, [ "live",$opt->{lang} ] ) if (($e{live}) && ($e{live} == 1)); 
    525                         push(@categories, [ Shepherd::Common::translate_category($e{genre}),$opt->{lang} ] ) if (($e{genre}) && ($e{genre} ne "")); 
     519                        # 'return' unseen 
    526520 
    527521                        my %video_details; 
     
    542536                        $tv_guide->{$channel}->{data}->{$event_id}->{'sub-title'} =     [[ $e{subtitle}, $opt->{lang} ]] if $e{subtitle}; 
    543537                        $tv_guide->{$channel}->{data}->{$event_id}->{'desc'} =          [[ $e{description_1}, $opt->{lang} ]] if $e{description_1}; 
    544                         $tv_guide->{$channel}->{data}->{$event_id}->{'category'} =      [ @categories ] if @categories; 
     538                        $tv_guide->{$channel}->{data}->{$event_id}->{'category'} =      [ &Shepherd::Common::generate_category($e{title}, $e{genre}, %e) ]; 
    545539                        $tv_guide->{$channel}->{data}->{$event_id}->{'country'} =       [[ $e{country}, $opt->{lang} ]] if $e{country}; 
    546540                        $tv_guide->{$channel}->{data}->{$event_id}->{'premiere'} =      [ 'premiere', $opt->{lang} ] if $e{premiere}; 
     
    548542                        $tv_guide->{$channel}->{data}->{$event_id}->{'credits'}{'actor'} = [ split(/, /, $e{main_cast}) ] if $e{main_cast}; 
    549543                        $tv_guide->{$channel}->{data}->{$event_id}->{'credits'}{'director'} = [ split(/, /, $e{director}) ] if $e{director}; 
     544                        $tv_guide->{$channel}->{data}->{$event_id}->{'credits'}{'writer'} = [ split(/, /, $e{writer}) ] if $e{writer}; # unseen 
    550545                        $tv_guide->{$channel}->{data}->{$event_id}->{'date'} =  $e{year_released} if $e{year_released}; 
    551546                        $tv_guide->{$channel}->{data}->{$event_id}->{'previously-shown'} = { } if $e{repeat}; 
  • branches/predictive/reconcilers/reconciler_mk2

    r930 r950  
    9696 
    9797my $progname = "reconciler_mk2"; 
    98 my $version = "0.35"; 
     98my $version = "0.36"; 
    9999 
    100100use LWP::UserAgent; 
     
    172172$reclogic{warn_on_overlapping_programmes_for_different_title} = 1; # do warn on overlapping programmes from same source with different names 
    173173$reclogic{warn_on_invalid_time_in_prog} = 1;            # do warn on a programme with a duration that is too long 
     174$reclogic{warn_on_tba_prog} = 1;                        # do warn on encountering To Be Advised shows 
    174175 
    175176# 
     
    10611062                $stats{bad_programme_duration_too_long}++; 
    10621063                return; 
     1064        } 
     1065 
     1066        # skip if 'To Be Advised' or 'TBA' 
     1067        if ($prog_title =~ /^to be advised$/i or $prog_title =~ /^tba$/i) 
     1068        { 
     1069            &log($reclogic{warn_on_tba_prog}, 
     1070                 (sprintf "WARNING: ignoring TBA programme '%s' on channel '%s' from %s: start '%s' stop '%s'; ignored.", 
     1071                 $prog_title, $prog_chan, $datafile,  
     1072                 ($prog->{start} ? $prog->{start} : "undef"),  
     1073                 ($prog->{stop} ? $prog->{stop} : "undef"))); 
     1074            return; 
    10631075        } 
    10641076 
  • branches/predictive/references/Shepherd/Common.pm

    r936 r950  
    33# Shepherd::Common library 
    44 
    5 my $version = '0.27'; 
     5my $version = '0.29'; 
    66 
    77# 
     
    770770########################################################################## 
    771771 
     772# if no category then guess from title for Sport, News, Infomercial 
     773# translates the words in category 
     774# types (final,premiere,return,live) are prepend to category 
     775# types (movie,sports,series,tvshow) are appended to category list 
     776sub generate_category 
     777{ 
     778    my ($title, $category, %type) = @_; 
     779 
     780    $type{sports} = 1 if ($title && $title=~/(^|\W)Sports?(\W|$)/i); 
     781    $type{sports} = 1 if ($category && $category=~/(^|\W)Sports?(\W|$)/i); 
     782 
     783    if ($category) { 
     784        if ($category eq "movie") { 
     785            $category = "Movie"; 
     786            $type{movie} = 1; 
     787        } elsif ($category eq "sports") { 
     788            $category = "Sports"; 
     789            $type{sports} = 1; 
     790        } elsif ($category eq "series") { 
     791            $category = "Series"; 
     792            $type{series} = 1; 
     793        } elsif ($category eq "tvshow") { 
     794            $category = "TVShow"; 
     795            $type{tvshow} = 1; 
     796        } 
     797        $category =~ s/Soap Opera/Soap/ig; 
     798        $category =~ s/Science and Technology/Science\/Nature/ig; 
     799        $category =~ s/Real Life/Reality/ig; 
     800        $category =~ s/Cartoon/Animation/ig; 
     801        $category =~ s/Family/Children/ig; 
     802        $category =~ s/Murder/Crime/ig; 
     803    } else { # !$category 
     804        if ($title) { 
     805            if ($title=~/(^|\W)News(\W|$)/i) { 
     806                $category = "News"; 
     807            } elsif ($title=~/(^|\W)Infomercials?(\W|$)/i) { 
     808                $category = "Infotainment"; 
     809            } 
     810        } 
     811        if (!$category) { 
     812            if ($type{movie}) { 
     813                $category = "Movie"; 
     814            } elsif ($type{sports}) { 
     815                $category = "Sports"; 
     816            } elsif ($type{series}) { 
     817                $category = "Series"; 
     818            } elsif ($type{tvshow}) { 
     819               $category = "TVShow"; 
     820            } 
     821        } 
     822    } 
     823 
     824    $category = "" if (!$category); 
     825    $category = "Live $category" if ($type{live}); 
     826    $category = "Return $category" if ($type{return}); 
     827    $category = "Premiere $category" if ($type{premiere}); 
     828    $category = "Final $category" if ($type{final}); 
     829    $category =~ s/^\s*(.*?)\s*$/$1/; 
     830 
     831    my @result; 
     832    @result = [ $category, "en"] if $category; 
     833    push(@result, [ "movie"  ]) if $type{movie}; 
     834    push(@result, [ "sports" ]) if $type{sports}; 
     835    push(@result, [ "series" ]) if $type{series}; 
     836    push(@result, [ "tvshow" ]) if $type{tvshow}; 
     837 
     838    return @result; 
     839} 
     840 
     841########################################################################## 
     842 
     843# (Adult Themes) 
     844# (Some Violence, Adult Themes, Supernatural Themes) 
     845# (Drug References, Adult Themes) 
     846# (Very Coarse Language, Sexual References, Drug References, Adult Themes, Nudity) 
     847# (Some Violence) 
     848# (Drug Use, Strong Adult Themes) 
     849# (Some Violence, Adult Themes) 
     850# (Some Coarse Language) 
     851# (Sexual References) 
     852# (Mild Coarse Language, Sexual References) 
     853# (Sex Scenes, Adult Themes, Supernatural Themes) 
     854# (Adult Themes, Medical Procedures) 
     855## (Qualifying - Sat) 
     856sub subrating 
     857{ 
     858  my $string = shift || ""; 
     859 
     860  my @subrating; 
     861  push(@subrating, "v") if $string =~ /Violence/i; 
     862  push(@subrating, "l") if $string =~ /Language/i; 
     863  push(@subrating, "s") if $string =~ /Sex/i; 
     864  push(@subrating, "d") if $string =~ /Drug/i; 
     865  push(@subrating, "a") if $string =~ /Adult/i; 
     866  push(@subrating, "n") if $string =~ /Nudity/i; 
     867  push(@subrating, "h") if $string =~ /Horror|Supernatural/i; 
     868  push(@subrating, "m") if $string =~ /Medical/i; 
     869 
     870  return join(",",@subrating); 
     871} 
     872 
     873########################################################################## 
     874 
    772875sub log 
    773876{ 
  • branches/predictive/status

    r938 r950  
    1 application     shepherd            1.2.24 
     1application     shepherd            1.2.26 
    22reference       channel_list        6 
    3 reference       Shepherd/Common.pm  0.27 
     3reference       Shepherd/Common.pm  0.29 
    44reference       Shepherd/MythTV.pm  0.6 
    5 grabber         yahoo7widget        1.92 
    6 grabber         rex                 3.5.9 
    7 grabber         abc_website         3.14 
     5grabber         yahoo7widget        1.93 
     6grabber         rex                 3.6.2 
     7grabber         abc_website         3.14-r1 
    88grabber         sbsnews_website     0.18 
    9 grabber         oztivo              1.13 
     9grabber         oztivo              1.14 
    1010grabber         jrobbo              0.16 
    1111grabber         yahoo7web           0.28-r1 
    1212grabber         foxtel_swf          0.24 
    1313grabber         channelnsw_gov      0.8 
    14 grabber         southerncross_website   0.14 
     14grabber         southerncross_website   0.16 
    1515grabber         ten_website         1.04 
    1616grabber         selectv_website     0.02 
    17 grabber         citysearch          2.0.2 
    18 grabber         acctv_website       0.02 
    19 reconciler      reconciler_mk2      0.35 
     17grabber         citysearch          2.0.3 
     18grabber         acctv_website       0.03 
     19reconciler      reconciler_mk2      0.36 
    2020postprocessor   imdb_augment_data   0.35 
    2121postprocessor   tvdb_augment_data   0.11