Changeset 950
- Timestamp:
- 10/17/07 23:51:41 (6 years ago)
- Location:
- branches/predictive
- Files:
-
- 11 modified
-
applications/shepherd (modified) (7 diffs)
-
grabbers/abc_website.conf (modified) (1 diff)
-
grabbers/acctv_website (modified) (4 diffs)
-
grabbers/citysearch (modified) (9 diffs)
-
grabbers/oztivo (modified) (3 diffs)
-
grabbers/rex (modified) (14 diffs)
-
grabbers/southerncross_website (modified) (7 diffs)
-
grabbers/yahoo7widget (modified) (4 diffs)
-
reconcilers/reconciler_mk2 (modified) (3 diffs)
-
references/Shepherd/Common.pm (modified) (2 diffs)
-
status (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/predictive/applications/shepherd
r932 r950 2 2 3 3 my $progname = 'shepherd'; 4 my $version = ' 1.2.24';4 my $version = '2.0.0'; 5 5 6 6 # tv_grab_au … … 1366 1366 $display_output = 1 if (!defined $display_output); 1367 1367 $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 } 1368 1374 1369 1375 my $prog_output = ""; … … 1817 1823 my $arg = join(":",@args); 1818 1824 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 1831 1825 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; 1843 1833 } 1844 1834 … … 4146 4136 4147 4137 # 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)) 4149 4139 { 4150 4140 $this_plugin->{$_} = 0; … … 4212 4202 } 4213 4203 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 4214 4214 # store plugin-specific stats 4215 4215 $this_plugin->{programmes}++; … … 4223 4223 # only analyze / check against policy if its a non optional channel 4224 4224 if (defined $channels->{$ch}) { 4225 # store channel-specific stats4226 $channel_data->{$ch}->{programmes}++;4227 $channel_data->{$ch}->{total_duration} += $this_duration;4228 4225 4229 4226 # programme is outside the timeslots we are interested in. … … 4233 4230 next; 4234 4231 } 4232 4233 # store channel-specific stats 4234 $channel_data->{$ch}->{programmes}++; 4235 $channel_data->{$ch}->{total_duration} += $this_duration; 4235 4236 4236 4237 # store timeslot info -
branches/predictive/grabbers/abc_website.conf
r790 r950 6 6 'regions' => '', 7 7 'option_ready' => '--version', 8 'option_set' => '--set',9 8 'desc' => 'guide data for ABC only from http://www.abc.net.au/tv/guide/netw/', 10 9 'max_days' => '14', -
branches/predictive/grabbers/acctv_website
r937 r950 23 23 my %stats; 24 24 my $o; 25 Shepherd::Common::program_begin(\$o, "acctv_website", "0.0 2", \%stats);25 Shepherd::Common::program_begin(\$o, "acctv_website", "0.03", \%stats); 26 26 27 27 my ($channels, $opt_channels, $gaps) = Shepherd::Common::read_channels($o, ("ACC")); … … 232 232 $prog->{$_} = $details_cache->{$cache_key}->{$_}; 233 233 } 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}); 238 235 $stats{cached_used}++; 239 236 return $prog; … … 289 286 if ($header eq 'Length') { 290 287 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()); 292 289 $td = shift @tds || last; 293 290 $header = $td->as_trimmed_text(); 291 $header =~ s/[^\x20-\x7f\x0a]//g; # remove 294 292 next; 295 293 } 296 294 my $length = ($1 < 3 ? ($1*60*60) : ($1*60)); 297 295 $prog->{length} = $length; 296 $prog->{stop} = $prog->{start} + $length; 298 297 Shepherd::Common::log("set length : $length") if ($o->{debug}); 299 298 } elsif ($header eq 'Genre') { … … 328 327 } 329 328 330 if (defined $prog->{length}) {331 $prog->{stop} = $prog->{start} + $prog->{length};332 delete $prog->{length};333 }334 335 329 return $prog; 336 330 } -
branches/predictive/grabbers/citysearch
r934 r950 4 4 # 5 5 6 my $version = '2.0. 2';6 my $version = '2.0.3'; 7 7 8 8 use strict; … … 336 336 337 337 $div = $tree->look_down(_tag => 'div', class => 'contentDetails'); 338 my %video;338 my (%video, $category, %type); 339 339 foreach my $tr ($div->look_down(_tag => 'tr')) 340 340 { … … 343 343 if ($1 eq 'Type') 344 344 { 345 push (@{$show->{category}}, $2) unless ($2 eq 'N/A');345 $category = &strip_whitespace($2); 346 346 } 347 347 elsif ($1 eq 'Country') … … 349 349 $show->{country} = $2; 350 350 } 351 elsif ($1 eq 'Language') 352 { 353 $show->{language} = $2; 354 } 351 355 elsif ($1 eq 'Cast') 352 356 { … … 356 360 } 357 361 } 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 } 358 376 elsif ($1 eq 'Duration') 359 377 { 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 } 364 385 } 365 386 } … … 388 409 { 389 410 $show->{'premiere'} = [ $info ]; 411 $type{premiere} = 1; 390 412 } 391 413 elsif ($info eq 'Live') 392 414 { 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; 394 424 } 395 425 elsif ($info eq 'Repeat') … … 399 429 elsif ($info eq 'Movie') 400 430 { 401 push @{$show->{category}}, 'movie';431 $type{movie} = 1; 402 432 } 403 433 else … … 430 460 } 431 461 $show->{video} = { %video } if (%video); 462 $show->{category} = [ &Shepherd::Common::generate_category( 463 $show->{title}, $category, %type) ]; 432 464 433 465 $tree->delete; … … 489 521 $p{$field} = [[ $p{$field}, $lang ]] if ($p{$field}); 490 522 } 523 $p{language} = [ $p{language}, $lang ] if ($p{language}); 491 524 $p{start} = &POSIX::strftime("%Y%m%d%H%M", localtime($p{start})); 492 525 $p{stop} = &POSIX::strftime("%Y%m%d%H%M", localtime($p{stop})); 493 526 $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 495 529 { 496 530 foreach (@{$p{category}}) -
branches/predictive/grabbers/oztivo
r900 r950 3 3 # OzTivo grabber 4 4 5 my $version = '1.1 3';5 my $version = '1.14'; 6 6 7 7 # Requires configuration! … … 440 440 my $l_min = int($local_tz / 100) * 60 + $local_tz % 100 % 60; 441 441 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)); 443 444 444 445 # Are we in DST? … … 493 494 494 495 # 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++) 496 497 { 497 498 my $t = $start + ($day * 24*60*60); -
branches/predictive/grabbers/rex
r888 r950 3 3 # "Rex" 4 4 5 my $version = '3. 5.9';5 my $version = '3.6.2'; 6 6 7 7 # An Australian TV Guide Grabber (a.k.a. tv_grab_au) … … 90 90 # 3.5.7 : Bugfix : parse "rest of day" guide page correctly 91 91 # 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) 92 103 93 104 use strict; … … 210 221 print stats(1); 211 222 223 Shepherd::Common::print_stats($progname, $version, $runtime, %stats); 224 212 225 exit 0; 213 226 … … 240 253 # Special bandwidth-saving URL for day 0 241 254 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 } 243 266 parse_guide($guidedata, $date) if ($guidedata); 244 267 } … … 249 272 for (1 .. 4) 250 273 { 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); 260 293 } 261 294 } … … 511 544 sub clean_cache 512 545 { 513 my $r = expand_date(localtime(time() - 3 600)."");546 my $r = expand_date(localtime(time() - 3*3600).""); 514 547 my $c = 0; 515 548 print "Removing cache items that finish earlier than $r.\n" if ($debug); … … 799 832 $block = $block->right(); 800 833 } 834 my ($category, %type); 801 835 foreach my $tag ($block->look_down('_tag' => 'tr')) 802 836 { … … 804 838 if ($str =~ /Genre:(.+)/) 805 839 { 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 { 806 846 $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); 810 853 } 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]]; 843 855 } 844 856 elsif ($str =~ /Cast: (.+)/) … … 846 858 $show->{'credits'}{'actor'} = [ split(/, /, strip_whitespace($1)) ]; 847 859 } 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 } 848 868 elsif ($str =~ /Year:\s*(\d+)/) 849 869 { 850 870 $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; 851 883 } 852 884 elsif ($str =~ /Other:(.+)/) … … 854 886 next unless (strip_whitespace($1)); 855 887 $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; 858 890 foreach my $bit (@extra) 859 891 { … … 864 896 { 865 897 $show->{'previously-shown'} = { }; 866 next; # Don't need this in the desc as well as it's867 # highlighted by MythTV868 898 } 869 899 elsif ($bit eq 'Widescreen') … … 871 901 $video{'aspect'} = '16:9'; 872 902 } 903 elsif ($bit eq 'High Definition') 904 { 905 $video{'quality'} = 'HDTV'; 906 } 873 907 elsif ($bit eq 'Closed Captions') 874 908 { 875 909 $show->{'subtitles'} = [ { 'type' => 'teletext' } ]; 876 next; # Just clutters up the desc 910 } 911 elsif ($bit eq 'New Episode') 912 { 913 $show->{'premiere'} = [ $bit ]; 877 914 } 878 915 elsif ($bit eq 'Premiere') 879 916 { 880 917 $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 } 887 932 $show->{'video'} = \%video if (%video); 888 933 } 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) ]; 902 938 903 939 $tree->delete(); … … 919 955 } 920 956 return 0; 921 }922 923 sub translate_category924 {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 $_;935 957 } 936 958 … … 1035 1057 if (@ARGV) 1036 1058 { 1037 print "\nERROR: Unknown option(s): @ARGV\n"; 1038 help(); 1059 print "\nWARNING: Ignoring unknown option(s): @ARGV\n\n"; 1039 1060 } 1040 1061 } -
branches/predictive/grabbers/southerncross_website
r832 r950 34 34 35 35 my $progname = "southerncross_website"; 36 my $version = "0.1 4";36 my $version = "0.16"; 37 37 38 38 #use LWP::UserAgent; … … 599 599 # <b>Sunday Afternoon Premiere Movie</b> - Rat 600 600 # <b>Sunday Afternoon Movie</b> - Evolution 601 my ($rating, $movie, $premiere, $final, $return, $series, $live);601 my ($rating, %type); 602 602 my $post_desc=""; 603 603 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); 606 606 &log("parse_page debug: Changing title $title to $subtitle") 607 607 if $opt->{debug}; … … 616 616 # (Series Final) 617 617 # (Series Return) 618 # (Replay) 618 619 ## (New Time) 619 620 ## (Qualifying) 621 ## (Special Presentation) 620 622 # $subtitle =~ , live from Aurora 621 623 if ($title =~ s/(\((.*)\))//) { 622 624 $post_desc .= $1; 623 625 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); 630 634 $prog->{title} = [[$title, $opt->{lang}]]; 631 635 &log("parse_page debug: title : $title $post_desc") if ($opt->{debug}); … … 649 653 650 654 if ($text) { 655 # - Live from Aurora 651 656 # Hosted by Mike Goldman & Bree Amer, this ... # how to parse all 652 657 # Hosted by Mike Goldman, Ryan Fitzgerald and Bree Amer. 653 658 # ^Guest Stars: Mel Gibson Studio ... # how to parse all 659 # Guests include: Damien Leith, Young Divas and Darren Hayes. 654 660 # Starring: $ 655 661 ## Insert Cast: Damon Wayans, Adam Sandler, Kristen Wilson, James Caan, 656 662 ## James Farentino (Cons Adv: Some Coarse Language, Some Violence, Sexual References) 657 # - Live from Aurora658 663 ## Featuring cartoons: Yu Gi Oh! Gx (Final), All Grown Up (Repeat), 659 664 ## Teenage Mutant Ninja Turtules (repeat) 665 $type{live} = 1 if ($text =~ /Live from/i); 660 666 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(/,|&|&|\Wand\W/i, $cast) ] if $cast; 666 672 $prog->{desc} = [[$text, $opt->{lang}]]; # desc 667 673 &log("parse_page debug: desc : $text") if $opt->{debug}; … … 682 688 $post_desc .= $text; 683 689 if ($rating) { 684 $rating .= " " . subrating($text);690 $rating .= " " . &Shepherd::Common::subrating($text); 685 691 } else { 686 $rating = subrating($text);692 $rating = &Shepherd::Common::subrating($text); 687 693 } 688 694 &log("parse_page debug: verbose rating : $text") if $opt->{debug}; … … 696 702 } 697 703 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}; 713 711 $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 # } 721 719 722 720 $progs->{$prog->{start}} = $prog; … … 737 735 { 738 736 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 (&|&|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 22 22 23 23 my $progname = "yahoo7widget"; 24 my $version = "1.9 2";24 my $version = "1.93"; 25 25 26 26 use XMLTV; … … 512 512 foreach my $field ('title', 'subtitle', 'description_1', 'main_cast', 'year_released', 'rating', 513 513 'genre', 'running_time', 'repeat', 'country', 'movie', 'premiere', 'final', 'captions', 'warnings', 514 'color', 'language', 'director', 'live' ) {514 'color', 'language', 'director', 'live', 'return') { 515 515 eval { $e{$field} = $event->getElementsByTagName("$field")->item(0)->getFirstChild->getNodeValue; }; 516 516 } 517 517 # other fields we dont pick up but exist in source xml data include: 518 518 # 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 526 520 527 521 my %video_details; … … 542 536 $tv_guide->{$channel}->{data}->{$event_id}->{'sub-title'} = [[ $e{subtitle}, $opt->{lang} ]] if $e{subtitle}; 543 537 $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) ]; 545 539 $tv_guide->{$channel}->{data}->{$event_id}->{'country'} = [[ $e{country}, $opt->{lang} ]] if $e{country}; 546 540 $tv_guide->{$channel}->{data}->{$event_id}->{'premiere'} = [ 'premiere', $opt->{lang} ] if $e{premiere}; … … 548 542 $tv_guide->{$channel}->{data}->{$event_id}->{'credits'}{'actor'} = [ split(/, /, $e{main_cast}) ] if $e{main_cast}; 549 543 $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 550 545 $tv_guide->{$channel}->{data}->{$event_id}->{'date'} = $e{year_released} if $e{year_released}; 551 546 $tv_guide->{$channel}->{data}->{$event_id}->{'previously-shown'} = { } if $e{repeat}; -
branches/predictive/reconcilers/reconciler_mk2
r930 r950 96 96 97 97 my $progname = "reconciler_mk2"; 98 my $version = "0.3 5";98 my $version = "0.36"; 99 99 100 100 use LWP::UserAgent; … … 172 172 $reclogic{warn_on_overlapping_programmes_for_different_title} = 1; # do warn on overlapping programmes from same source with different names 173 173 $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 174 175 175 176 # … … 1061 1062 $stats{bad_programme_duration_too_long}++; 1062 1063 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; 1063 1075 } 1064 1076 -
branches/predictive/references/Shepherd/Common.pm
r936 r950 3 3 # Shepherd::Common library 4 4 5 my $version = '0.2 7';5 my $version = '0.29'; 6 6 7 7 # … … 770 770 ########################################################################## 771 771 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 776 sub 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) 856 sub 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 772 875 sub log 773 876 { -
branches/predictive/status
r938 r950 1 application shepherd 1.2.2 41 application shepherd 1.2.26 2 2 reference channel_list 6 3 reference Shepherd/Common.pm 0.2 73 reference Shepherd/Common.pm 0.29 4 4 reference Shepherd/MythTV.pm 0.6 5 grabber yahoo7widget 1.9 26 grabber rex 3. 5.97 grabber abc_website 3.14 5 grabber yahoo7widget 1.93 6 grabber rex 3.6.2 7 grabber abc_website 3.14-r1 8 8 grabber sbsnews_website 0.18 9 grabber oztivo 1.1 39 grabber oztivo 1.14 10 10 grabber jrobbo 0.16 11 11 grabber yahoo7web 0.28-r1 12 12 grabber foxtel_swf 0.24 13 13 grabber channelnsw_gov 0.8 14 grabber southerncross_website 0.1 414 grabber southerncross_website 0.16 15 15 grabber ten_website 1.04 16 16 grabber selectv_website 0.02 17 grabber citysearch 2.0. 218 grabber acctv_website 0.0 219 reconciler reconciler_mk2 0.3 517 grabber citysearch 2.0.3 18 grabber acctv_website 0.03 19 reconciler reconciler_mk2 0.36 20 20 postprocessor imdb_augment_data 0.35 21 21 postprocessor tvdb_augment_data 0.11
