Changeset 977

Show
Ignore:
Timestamp:
12/06/07 06:25:12 (5 years ago)
Author:
paul
Message:

flag_aus_hdtv: copysd in now default for new installs, only flag HD on 7HD special programs if known to be, simplify sd program removal, fill gaps between high definition programs

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/postprocessors/flag_aus_hdtv

    r975 r977  
    1313 
    1414my $progname = "flag_aus_hdtv"; 
    15 my $version = "0.25"; 
     15my $version = "0.26"; 
    1616 
    1717$| = 1; 
     
    7171my $channels, my $reverse_channels, my $detailed_reverse_channels, my $opt_channels, my %channel_xmlid_to_opt_channel_xmlid; 
    7272my $d, my $ar, my $sd, my $hd; 
     73my $gapchannel, my $gaplaststop; 
    7374my $override_settings = { }; 
    7475my %amp = ( nbsp => ' ', qw{ amp & lt < gt > apos ' quot " } ); 
     
    8182$opt->{region} = 94; 
    8283$opt->{debug} = 1; 
    83 $opt->{action} = "copy"; 
     84$opt->{action} = "copysd"; 
    8485 
    8586&parse_command_line; 
     
    9596&read_config_file($progname.".config",0); 
    9697&apply_setting_overrides; 
    97  
    98 # 5/12/2007 set everyones action to "copy", so in a few days can change default to "copysd" 
    99 if (!defined $override_settings->{action}) {  
    100         $override_settings->{action} = "copy"; 
    101         &write_config; 
    102 } 
    10398 
    10499&read_config_file($opt->{channels_file},1); 
     
    186181 
    187182  --action=(policy)    policy can be one of: 
    188                         move - move prog to HD channel (remove it from SD channel) 
    189                         copy - copy prog to HD channel (keep it in SD channel also) (default) 
    190                         copysd - copy all progs to HD channel, flaging HD ones 
     183                        move - move HD progs to HD channel (remove it from SD channel) 
     184                        copy - copy HD progs to HD channel (keep it in SD channel also) 
     185                        copysd - copy all progs to HD channel, flagging HD ones (default) 
    191186  --notag              don't tag with HD flags (default: do) 
    192187 
     
    210205 
    211206        die "'--channels_file {file}' must be specified. see --help for details.\n" if (!$opt->{channels_file}); 
    212         die "unknown --action policy, see --help for details.\n" if ($opt->{action} !~ /^(copysd|copy|move)$/); 
     207        die "unknown --action policy, see --help for details.\n" 
     208                        if (($opt->{action} ne "move") && ($opt->{action} ne "copy") && ($opt->{action} ne "copysd")) 
    213209} 
    214210 
     
    228224        } elsif ($setting eq "action") { 
    229225                die "--set value must be copy/move for setting '$setting'.\n" 
    230                                 if (($val ne "copysd") && ($val ne "copy") && ($val ne "move")); 
     226                                if (($val ne "move") && ($val ne "copy") && ($val ne "copysd")); 
    231227                $override_settings->{$setting} = $val; 
    232228                printf "%s: override parameter %s: %s\n", $progname, $setting, $val; 
     
    622618        my $prog=shift; 
    623619        my $this_chan = $prog->{channel}; 
    624         my $this_title; 
    625  
    626         $this_title = $prog->{title}->[0]->[0] 
    627           if (($prog->{title}) && ($prog->{title}->[0]) && ($prog->{title}->[0]->[0])); 
    628         # print "got programme ".Dumper($prog); 
    629  
    630         goto NOMATCH if (!defined $this_chan); 
    631         goto NOMATCH if (!defined $this_title); 
    632  
    633         # process later high definition channel programmes 
    634         if (defined $reverse_channels->{$this_chan} && 
    635                         defined $hd_to_sds->{$reverse_channels->{$this_chan}}) { 
    636                 return if $this_title eq "See main channel's listings for programming details"; 
    637 #print "process later high definition channel programmes - $this_title - $reverse_channels->{$this_chan}\n"; 
    638                 $prog->{video}->{quality} = "HDTV" unless (defined $opt->{notag}); 
    639                 $ar->{$reverse_channels->{$this_chan}}->{Shepherd::Common::parse_xmltv_date($prog->{start})} = $prog; 
    640                 return; 
    641         } 
    642  
    643         # keep a copy of standard definition related to high definition channel programmes for program removal later 
     620        return if (!defined $this_chan); 
     621 
     622        # keep a copy of standard definition related to argumenting high definition channel programmes for program removal later 
    644623        if (defined $channel_xmlid_to_opt_channel_xmlid{$this_chan} && 
    645624                        defined $detailed_reverse_channels->{$channel_xmlid_to_opt_channel_xmlid{$this_chan}}) { 
     
    647626                                {Shepherd::Common::parse_xmltv_date($prog->{start})} = $prog; 
    648627        } 
     628 
     629        my $this_title; 
     630        $this_title = $prog->{title}->[0]->[0] 
     631          if (($prog->{title}) && ($prog->{title}->[0]) && ($prog->{title}->[0]->[0])); 
     632        # print "got programme ".Dumper($prog); 
     633        goto NOMATCH if (!defined $this_title); 
    649634 
    650635        # if programme is already marked as HDTV, just skip all of this 
     
    680665 
    681666NOMATCH: 
     667        # process later argumenting high definition channel programmes 
     668        if (defined $reverse_channels->{$this_chan} && 
     669                        defined $hd_to_sds->{$reverse_channels->{$this_chan}}) { 
     670                return if defined $this_title && $this_title eq "See main channel's listings for programming details"; 
     671                # just because its on 7HD doesn't make it high definition 
     672                $ar->{$reverse_channels->{$this_chan}}->{Shepherd::Common::parse_xmltv_date($prog->{start})} = $prog; 
     673                return; 
     674        } 
     675 
    682676        $writer->write_programme($prog); 
    683677 
    684         if ($opt->{action} =~ /copysd/ && defined $channel_xmlid_to_opt_channel_xmlid{$this_chan}) { 
    685                 delete $prog->{video}->{quality}; 
     678        # copy to high definition channel 
     679        if ($opt->{action} eq "copysd" && defined $channel_xmlid_to_opt_channel_xmlid{$this_chan}) { 
    686680                $prog->{channel} = $channel_xmlid_to_opt_channel_xmlid{$this_chan}; 
    687681                # but don't write HD channel until all programs read 
     
    694688        $d->{seenprog}->{$this_title}++; 
    695689        $prog->{video}->{aspect} = "16:9"; # widescreen 
     690 
     691        # process later argumenting high definition channel programmes 
     692        if (defined $reverse_channels->{$this_chan} && 
     693                        defined $hd_to_sds->{$reverse_channels->{$this_chan}}) { 
     694                return if defined $this_title && $this_title eq "See main channel's listings for programming details"; 
     695                $prog->{video}->{quality} = "HDTV" unless (defined $opt->{notag}); 
     696                $ar->{$reverse_channels->{$this_chan}}->{Shepherd::Common::parse_xmltv_date($prog->{start})} = $prog; 
     697                return; 
     698        } 
    696699 
    697700        if (!defined $channel_xmlid_to_opt_channel_xmlid{$this_chan}) { 
     
    701704                $stats{rewrote_prog_as_hdtv_inplace}++; 
    702705        } else { 
    703                 if ($opt->{action} =~ /copy/) { 
     706                if ($opt->{action} eq "copy" || $opt->{action} eq "copysd") { 
    704707                        # SD channel 
    705708                        delete $prog->{video}->{quality}; 
     
    712715                $prog->{channel} = $channel_xmlid_to_opt_channel_xmlid{$this_chan}; 
    713716                # but don't write HD channel until all programs read 
    714 #print "but don't write HD channel until all programs read - $this_title - $hd_chan\n"; 
    715717                $hd->{$this_chan}->{Shepherd::Common::parse_xmltv_date($prog->{start})} = $prog; 
    716718        } 
     
    718720} 
    719721 
    720 sub write_hd    # currently doesn't fill any gaps between programs 
     722sub write_hd 
    721723{ 
    722724        # remove from argument channel identical (time, title, sub-title) programs found on sd channel 
    723         foreach my $hdchannel (keys %$ar) { 
    724 #print "removal for hdchannel $hdchannel\n"; 
    725  
    726                 my @aprogs = sort {$a <=> $b} keys %{$ar->{$hdchannel}}; 
    727                 my $aprog = $ar->{$hdchannel}->{shift @aprogs}; 
    728  
    729                 my @progs = sort {$a <=> $b} keys %{$sd->{$hdchannel}}; 
    730                 my $prog = $sd->{$hdchannel}->{shift @progs}; 
    731                 last if !defined $prog; 
    732                 my $start = Shepherd::Common::parse_xmltv_date($prog->{start}); 
    733                 my $stop = Shepherd::Common::parse_xmltv_date($prog->{stop}); 
    734 #print "found programs\n"; 
    735  
    736                 while (defined $aprog) { 
    737                         my $astart = Shepherd::Common::parse_xmltv_date($aprog->{start}); 
    738                         my $astop = Shepherd::Common::parse_xmltv_date($aprog->{stop}); 
    739  
    740                         # skip any sd programs before this argument programs time 
    741                         while (defined $prog && $start < $astart) { 
    742 #print "skip prog\n"; 
    743                                 $prog = $sd->{$hdchannel}->{shift @progs}; 
    744                                 last if !defined $prog; 
    745                                 $start = Shepherd::Common::parse_xmltv_date($prog->{start}); 
    746                                 $stop = Shepherd::Common::parse_xmltv_date($prog->{stop}); 
     725        foreach my $channel (keys %$ar) { 
     726                next if !defined $sd->{$channel}; 
     727                foreach my $start (keys %{$ar->{$channel}}) { 
     728                        if (defined $sd->{$channel}->{$start}) { 
     729                                my $aprog = $ar->{$channel}->{$start}; 
     730                                my $prog = $sd->{$channel}->{$start}; 
     731 
     732                                if (Shepherd::Common::parse_xmltv_date($aprog->{stop}) == 
     733                                                Shepherd::Common::parse_xmltv_date($prog->{stop}) && 
     734                                                (!defined $aprog->{title} || !defined $prog->{title} || 
     735                                                        $aprog->{title}->[0]->[0] eq $prog->{title}->[0]->[0]) && 
     736                                                (!defined $aprog->{'sub-title'} || !defined $prog->{'sub-title'} || 
     737                                                        $aprog->{'sub-title'}->[0]->[0] eq $prog->{'sub-title'}->[0]->[0])){ 
     738                                        delete $ar->{$channel}->{$start}; 
     739                                } 
    747740                        } 
    748                         last if !defined $prog; 
    749  
    750                         if ($astart == $start && $astop == $stop && 
    751                                         (!defined $aprog->{title} || !defined $prog->{title} || 
    752                                                 $aprog->{title}->[0]->[0] eq $prog->{title}->[0]->[0]) && 
    753                                         (!defined $aprog->{'sub-title'} || !defined $prog->{'sub-title'} || 
    754                                                 $aprog->{'sub-title'}->[0]->[0] eq $prog->{'sub-title'}->[0]->[0])) { 
    755 #print "delete aprog\n"; 
    756                                 delete $ar->{$hdchannel}->{$astart}; 
    757                         } 
    758  
    759                         $aprog = $ar->{$hdchannel}->{shift @aprogs}; 
    760                 } 
    761         } 
    762  
     741                } 
     742        } 
     743 
     744        # write high definition channel programs argumenting as needed 
    763745        foreach my $xmlid (keys %$hd) { 
    764 #print "processing channel xmlid $xmlid\n"; 
    765  
    766746                my ($argument, @aprogs, $aprog); 
    767747 
     
    784764                                $aprog = $ar->{$argument}->{shift @aprogs}; 
    785765                        } 
    786 #print "first argument program at $aprog->{start}\n"; 
    787766                } 
    788767 
     
    796775                                                Shepherd::Common::parse_xmltv_date($prog->{stop})) { 
    797776                                $aprog->{channel} = $channel_xmlid_to_opt_channel_xmlid{$xmlid}; 
     777                                &gapfill($aprog->{channel}, $aprog->{start}, $aprog->{stop}); 
    798778                                $writer->write_programme($aprog); 
    799779                                $stats{wrote_prog_into_hdtv_channel}++; 
    800  
    801 #print "wrote argument program $aprog->{title}->[0]->[0]\n"; 
    802780 
    803781                                # drop programs that conflict with argument program 
    804782                                while (Shepherd::Common::parse_xmltv_date($prog->{start}) < 
    805783                                                Shepherd::Common::parse_xmltv_date($aprog->{stop})) { 
    806 #print "dropping conflicting program $prog->{title}->[0]->[0]\n"; 
    807784                                        $prog = $hd->{$xmlid}->{shift @progs}; 
    808785                                } 
     
    811788                        } 
    812789 
     790                        &gapfill($prog->{channel}, $prog->{start}, $prog->{stop}); 
    813791                        $writer->write_programme($prog); 
    814792                        $stats{wrote_prog_into_hdtv_channel}++; 
     
    820798                while (defined $aprog) { 
    821799                        $aprog->{channel} = $channel_xmlid_to_opt_channel_xmlid{$xmlid}; 
     800                        &gapfill($prog->{channel}, $prog->{start}, $prog->{stop}); 
    822801                        $writer->write_programme($aprog); 
    823802                        $stats{wrote_prog_into_hdtv_channel}++; 
    824803 
    825 #print "wrote left over argument program $aprog->{title}->[0]->[0]\n"; 
    826  
    827804                        $aprog = $ar->{$argument}->{shift @aprogs}; 
    828805                } 
     806        } 
     807} 
     808 
     809sub gapfill 
     810{ 
     811        my $prog; 
     812        $prog->{channel} = shift; 
     813        $prog->{start} = $gaplaststop; 
     814        $prog->{stop} = shift; 
     815        $gaplaststop = shift; 
     816 
     817        if (defined $prog->{start} && defined $gapchannel && $gapchannel eq $prog->{channel}) { 
     818                if (Shepherd::Common::parse_xmltv_date($prog->{start}) != 
     819                                Shepherd::Common::parse_xmltv_date($prog->{stop})) { 
     820                        if ($opt->{action} eq "copysd") { 
     821                                $prog->{title}->[0]->[0] = "Gap"; 
     822                        } else { 
     823                                $prog->{title}->[0]->[0] = "Upscaled SD or Loop"; 
     824                                $prog->{desc}->[0]->[0] = 
     825                                                "This can be populated with programs by changing your Shepherd settings."; 
     826                        } 
     827                        $writer->write_programme($prog); 
     828                        $stats{wrote_gapfill_into_hdtv_channel}++; 
     829                } 
     830        } else { 
     831                $gapchannel = $prog->{channel}; 
    829832        } 
    830833} 
  • trunk/status

    r976 r977  
    1919postprocessor   imdb_augment_data   0.35 
    2020postprocessor   tvdb_augment_data   0.11 
    21 postprocessor   flag_aus_hdtv       0.25 
     21postprocessor   flag_aus_hdtv       0.26 
    2222postprocessor   augment_timezone    0.17