Changeset 35

Show
Ignore:
Timestamp:
10/06/06 22:52:08 (7 years ago)
Author:
lincoln
Message:

first pass at title_translation_table where grabbers call things different names - just start storing differences .. for now

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • shepherd

    r34 r35  
    123123# postprocessing 
    124124my $postprocessors = { }; 
     125my $title_translation_table = { }; 
    125126my $langs = [ 'en' ]; 
    126127my $num_timeslots; 
     
    539540    my @proglist = [ ]; 
    540541    my @position_pointer = [ ]; 
     542    my @grabber_order = [ ]; 
    541543    my $num_grabbers = 0; 
    542544    my $pref_order; 
     
    545547    foreach my $proggy (sort { $grabbers->{$a}->{order} <=> $grabbers->{$b}->{order} } keys %$grabbers) { 
    546548        if ((!$grabbers->{$proggy}->{disabled}) && ($plugin_data->{$proggy}) && ($plugin_data->{$proggy}->{valid})) { 
     549            $grabber_order[$num_grabbers] = $proggy; 
    547550            my $orig_prog = $plugin_data->{$proggy}->{xmltv}->[3]; 
    548551            my $prognum = 0; 
     
    686689 
    687690                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]; 
    688692                $startpoint = $chosen_prog->{'start_epoch'}; 
    689693                $stoppoint = $chosen_prog->{'stop_epoch'}; 
     
    691695 
    692696                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; 
    695698 
    696699                # 
    697                 # 5a. see if we have it duplicated from multiple grabbers (with fuzz -/+ 5 mins max), -/+ 2.5mins for programmes <= 15 mins 
    698                 # 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                 
    700703                my $start1, my $start2, my $stop1, my $stop2; 
    701704 
     
    716719                } 
    717720 
    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", 
    719756                    $start1,$start2,($start2-$start1),$stop1,$stop2,($stop2-$stop1) if $recdebug; 
    720757 
     
    732769                        my $match_prog = $proglist[$i]->[($position_pointer[$i])]; 
    733770 
    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, 
    735772                            $match_prog->{'start_epoch'},$match_prog->{'stop_epoch'}, 
    736773                            ${XMLTV::best_name($langs,$match_prog->{'title'})}[0] if $recdebug; 
     
    13451382    open(CONF, ">$config_file") or die "cannot write to $config_file: $!"; 
    13461383    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" ]); 
    13491386    close CONF; 
    13501387    print "\nUpdated configuration file $config_file.\n" if ($debug);