Changeset 35
Legend:
- Unmodified
- Added
- Removed
-
shepherd
r34 r35 123 123 # postprocessing 124 124 my $postprocessors = { }; 125 my $title_translation_table = { }; 125 126 my $langs = [ 'en' ]; 126 127 my $num_timeslots; … … 539 540 my @proglist = [ ]; 540 541 my @position_pointer = [ ]; 542 my @grabber_order = [ ]; 541 543 my $num_grabbers = 0; 542 544 my $pref_order; … … 545 547 foreach my $proggy (sort { $grabbers->{$a}->{order} <=> $grabbers->{$b}->{order} } keys %$grabbers) { 546 548 if ((!$grabbers->{$proggy}->{disabled}) && ($plugin_data->{$proggy}) && ($plugin_data->{$proggy}->{valid})) { 549 $grabber_order[$num_grabbers] = $proggy; 547 550 my $orig_prog = $plugin_data->{$proggy}->{xmltv}->[3]; 548 551 my $prognum = 0; … … 686 689 687 690 my $chosen_prog = $proglist[$earliest_programme_slot]->[($position_pointer[$earliest_programme_slot])]; 691 my $chosen_prog_name = ${XMLTV::best_name($langs,$chosen_prog->{'title'})}[0]; 688 692 $startpoint = $chosen_prog->{'start_epoch'}; 689 693 $stoppoint = $chosen_prog->{'stop_epoch'}; … … 691 695 692 696 printf "REC#4: chosen programme is from grabber %d: start %d, end %d, duration %d: \"%s\"\n", 693 $earliest_programme_slot,$startpoint,$stoppoint,($stoppoint-$startpoint), 694 ${XMLTV::best_name($langs,$chosen_prog->{'title'})}[0] if $recdebug; 697 $earliest_programme_slot,$startpoint,$stoppoint,($stoppoint-$startpoint),$chosen_prog_name if $recdebug; 695 698 696 699 # 697 # 5a. see if we have it duplicated from multiple grabbers (with fuzz -/+ 5 mins max), -/+ 2.5mins for programmes <= 15 mins698 # TODO (FUTURE): should really do an exact start/stop match as a first pass, then do the fuzz afterwards.. 699 700 # 5a. see if we have it duplicated from multiple grabbers, first with exact match 701 # 5b. then with fuzz -/+ 5 mins max, -/+ 2.5mins for programmes <= 15 mins 702 700 703 my $start1, my $start2, my $stop1, my $stop2; 701 704 … … 716 719 } 717 720 718 printf "REC#5: looking in other grabbers for matching programmes within timeslot start %d-%d (%d) and end %d-%d (%d)\n", 721 printf "REC#5a: looking in other grabbers for matching programmes within timeslot start %d and end %d (%d)\n",$startpoint,$stoppoint,($stoppoint-$startpoint) if $recdebug; 722 for (my $i=0; $i < $num_grabbers; $i++) { 723 next if ($i == $earliest_programme_slot); 724 next if ($position_pointer[$i] == -1); 725 if ((defined $proglist[$i]->[($position_pointer[$i])]) && 726 ($proglist[$i]->[($position_pointer[$i])]->{'channel'} eq $channels->{$ch}) && 727 ($proglist[$i]->[($position_pointer[$i])]->{'start_epoch'} == $startpoint) && 728 ($proglist[$i]->[($position_pointer[$i])]->{'stop_epoch'} == $stoppoint)) { 729 # winner .. matches our criteria ... 730 my $match_prog = $proglist[$i]->[($position_pointer[$i])]; 731 my $match_prog_name = ${XMLTV::best_name($langs,$match_prog->{'title'})}[0]; 732 733 printf "REC#5a: found programme on grabber %d: start %d, end %d: \"%s\"\n", $i, 734 $match_prog->{'start_epoch'},$match_prog->{'stop_epoch'},$match_prog_name if $recdebug; 735 736 if ($chosen_prog_name ne $match_prog_name) { 737 # names differ - save it in our translation table for future reference! 738 $title_translation_table->{$grabber_order[$i]}->{$match_prog_name} = $chosen_prog_name; 739 printf "REC#5a: title-translation: higher-preference grabber '%s' called programme \"%s\" compared to '%s' calling it \"%s\"\n", 740 $grabber_order[$earliest_programme_slot],$chosen_prog_name,$grabber_order[$i],$chosen_prog_name if $recdebug; 741 } 742 743 foreach my $field (keys %{$match_prog}) { 744 next if ($field eq "start_epoch"); 745 next if ($field eq "stop_epoch"); 746 if (!defined $new_prog_entry->{$field}) { 747 printf "REC#5a: adding field \"%s\"\n",$field if $recdebug; 748 $new_prog_entry->{$field} = $match_prog->{$field}; 749 # TODO (FUTURE): should we add to programme description to say where we got what data from? 750 } 751 } 752 } 753 } 754 755 printf "REC#5b: looking in other grabbers for matching programmes within timeslot start %d-%d (%d) and end %d-%d (%d)\n", 719 756 $start1,$start2,($start2-$start1),$stop1,$stop2,($stop2-$stop1) if $recdebug; 720 757 … … 732 769 my $match_prog = $proglist[$i]->[($position_pointer[$i])]; 733 770 734 printf "REC#5 : found programme on grabber %d: start %d, end %d: \"%s\"\n", $i,771 printf "REC#5b: found programme on grabber %d: start %d, end %d: \"%s\"\n", $i, 735 772 $match_prog->{'start_epoch'},$match_prog->{'stop_epoch'}, 736 773 ${XMLTV::best_name($langs,$match_prog->{'title'})}[0] if $recdebug; … … 1345 1382 open(CONF, ">$config_file") or die "cannot write to $config_file: $!"; 1346 1383 print CONF Data::Dumper->Dump( 1347 [$region, $pref_order, $mirror_site, $grabbers, $postprocessors],1348 ["region", "pref_order", "mirror_site", "grabbers", "postprocessors" ]);1384 [$region, $pref_order, $mirror_site, $grabbers, $postprocessors, $title_translation_table ], 1385 ["region", "pref_order", "mirror_site", "grabbers", "postprocessors", "title_translation_table" ]); 1349 1386 close CONF; 1350 1387 print "\nUpdated configuration file $config_file.\n" if ($debug);
