Changeset 730

Show
Ignore:
Timestamp:
06/03/07 02:10:29 (6 years ago)
Author:
lincoln
Message:

commit genre/actors/writers/directors info into appropriate XMLTV fields, always augment description with "Overview" if there is no description

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • postprocessors/tvdb_augment_data

    r729 r730  
    1515#  changelog: 
    1616#    0.01 31may07 ltd   initial version 
    17 #                       as per trac ticket #31 
     17#    0.02 fill in actors/writers/directors, augment description if there is none 
    1818 
    1919use strict; 
    2020 
    2121my $progname = "tvdb_augment_data"; 
    22 my $version = "0.01"; 
     22my $version = "0.02"; 
    2323my $mirrorlist_url = 'http://thetvdb.com/interfaces/GetMirrors.php'; 
    2424 
     
    2727use Getopt::Long; 
    2828use HTML::TreeBuilder; 
    29 use Data::Dumper; 
    3029use Storable; 
    3130use Shepherd::Common; 
     31use Data::Dumper; 
    3232 
    3333# 
     
    7373        'cache_title_for=i'     => \$opt->{cache_title_for}, 
    7474        'dont-augment-desc'     => \$opt->{dont_augment_desc}, 
     75 
     76        'dump-cache'            => \$opt->{dump_cache}, 
    7577 
    7678        'output=s'              => \$opt->{output_file}, 
     
    8789        'v'                     => \$opt->{version}); 
    8890 
     91&dump_cache if (defined $opt->{dump_cache}); 
     92&set_settings if (defined $opt->{set}); 
     93 
    8994if ($opt->{version} || $opt->{desc} || $opt->{help} || $opt->{ready} || 
    9095    $opt->{output_file} eq "" || (scalar @ARGV == 0)) { 
     
    157162        dont_augment_desc:1/0 (don't / do) 
    158163 
     164  --dump-cache         (debugging) show cache contents 
     165 
    159166EOF 
    160167; 
     168} 
     169 
     170############################################################################## 
     171 
     172sub dump_cache 
     173{ 
     174        &read_cache; 
     175        $Data::Dumper::Indent = 1; 
     176        print Dumper($data_cache); 
     177        exit(0); 
    161178} 
    162179 
     
    291308                        $title = lc($prog->{title}->[0]->[0]) if ((defined $prog->{title}) && (defined $prog->{title}->[0]) && (defined $prog->{title}->[0]->[0])); 
    292309                        $subtitle = lc($prog->{'sub-title'}->[0]->[0]) if ((defined $prog->{'sub-title'}) && (defined $prog->{'sub-title'}->[0]) && (defined $prog->{'sub-title'}->[0]->[0])); 
     310 
     311                        Shepherd::Common::log(" - prog ".(defined $title ? $title : "")) if (defined $opt->{debug}); 
     312                        if ((!defined $prog->{desc}) || (!defined $prog->{desc}->[0]) || (!defined $prog->{desc}->[0]->[0])) { 
     313                                # no existing description on programme. lets see if we can add one 
     314 
     315                                if ((defined $title) && (defined $data_cache->{prog}->{$title})) { 
     316                                        my $new_desc = ""; 
     317                                        $new_desc .= $data_cache->{prog}->{$title}->{SERIES}->{Overview} 
     318                                          if ((defined $data_cache->{prog}->{$title}->{SERIES}) && 
     319                                              (defined $data_cache->{prog}->{$title}->{SERIES}->{Overview}) && 
     320                                              ($data_cache->{prog}->{$title}->{SERIES}->{Overview} ne "")); 
     321 
     322                                        $new_desc .= ($new_desc ne "" ? "\n\n" : ""). 
     323                                          $data_cache->{prog}->{$title}->{$subtitle}->{Overview} 
     324                                          if ((defined $subtitle) && 
     325                                              (defined $data_cache->{prog}->{$title}->{$subtitle}) && 
     326                                              (defined $data_cache->{prog}->{$title}->{$subtitle}->{Ovewview}) && 
     327                                              ($data_cache->{prog}->{$title}->{$subtitle}->{Ovewview} ne "")); 
     328 
     329                                        if ($new_desc ne "") { 
     330                                                $stats{inserted_new_title}++; 
     331                                                $prog->{desc}->[0]->[0] = $new_desc; 
     332                                                Shepherd::Common::log("   existing desc was blank, added '$new_desc'") if (defined $opt->{debug}); 
     333                                        } 
     334                                } 
     335                        } 
     336 
     337 
    293338                        my $desc = ""; 
    294339 
     
    308353                                # Genre 
    309354                                if ((defined $series_data->{Genre}) && ($series_data->{Genre} ne "")) { 
     355                                        my $g = Shepherd::Common::translate_category($series_data->{Genre}); 
    310356                                        my $found_genre = 0; 
    311357                                        foreach my $category (@{($prog->{category})}) { 
    312                                                 $found_genre++ if (lc($series_data->{Genre}) eq lc($category->[0])); 
    313                                         } 
    314                                         push(@{($prog->{category})},[$series_data->{Genre}]) if (!$found_genre); 
    315                                 } 
    316  
    317                                 # don't do Actors for now - thetvdb.com has multiple formats for them 
     358                                                $found_genre++ if (lc($g) eq lc($category->[0])); 
     359                                        } 
     360                                        if (!$found_genre) { 
     361                                                push(@{($prog->{category})},[$g]); 
     362                                                Shepherd::Common::log("   added genre '$g'") if (defined $opt->{debug}); 
     363                                        } 
     364                                } 
     365 
     366                                # Actors 
     367                                if ((defined $series_data->{Actors}) && ($series_data->{Actors} ne "") && 
     368                                    (defined $prog->{credits}) && (defined $prog->{credits}->{actor})) { 
     369                                        foreach my $cast (split(/[\|,]/,$series_data->{Actors})) { 
     370                                                $cast =~ s/(^\s+|\s+$)//g; 
     371                                                next if ($cast eq ""); 
     372                                                my $found_cast = 0; 
     373                                                foreach my $a (@{($prog->{credits}->{actor})}) { 
     374                                                        $found_cast++ if (lc($cast) eq lc($a)); 
     375                                                } 
     376                                                if (!$found_cast) { 
     377                                                        push(@{($prog->{credits}->{actor})},$cast); 
     378                                                        Shepherd::Common::log("   added series actor '$cast'") if (defined $opt->{debug}); 
     379                                                } 
     380                                        } 
     381                                } 
    318382                        } 
    319383 
     
    340404                                                } 
    341405                                        } 
    342                                         push (@{($prog->{url})},$episode_data->{ShowURL}) if (!$found_url); 
    343                                 } 
    344  
    345                                 # don't do GuestStars, Director, Writer for now - thetvdb.com has multiple formats for them 
     406                                        if (!$found_url) { 
     407                                                push (@{($prog->{url})},$episode_data->{ShowURL}); 
     408                                                Shepherd::Common::log("   added url '".$episode_data->{ShowURL}."'") if (defined $opt->{debug}); 
     409                                        } 
     410                                } 
     411 
     412                                # GuestStars 
     413                                if ((defined $episode_data->{GuestStars}) && ($episode_data->{GuestStars} ne "") && 
     414                                    (defined $prog->{credits}) && (defined $prog->{credits}->{actor})) { 
     415                                        foreach my $cast (split(/[\|,]/,$episode_data->{GuestStars})) { 
     416                                                $cast =~ s/(^\s+|\s+$)//g; 
     417                                                next if ($cast eq ""); 
     418                                                my $found_cast = 0; 
     419                                                foreach my $a (@{($prog->{credits}->{actor})}) { 
     420                                                        $found_cast++ if (lc($cast) eq lc($a)); 
     421                                                } 
     422                                                if (!$found_cast) { 
     423                                                        push(@{($prog->{credits}->{actor})},$cast); 
     424                                                        Shepherd::Common::log("   added guest star '$cast'") if (defined $opt->{debug}); 
     425                                                } 
     426                                        } 
     427                                } 
     428 
     429                                # Director 
     430                                if ((defined $episode_data->{Director}) && ($episode_data->{Director} ne "") && 
     431                                    (defined $prog->{credits}) && (defined $prog->{credits}->{director})) { 
     432                                        foreach my $cast (split(/[\|,]/,$episode_data->{Director})) { 
     433                                                $cast =~ s/(^\s+|\s+$)//g; 
     434                                                next if ($cast eq ""); 
     435                                                my $found_cast = 0; 
     436                                                foreach my $d (@{($prog->{credits}->{director})}) { 
     437                                                        $found_cast++ if (lc($cast) eq lc($d)); 
     438                                                } 
     439                                                if (!$found_cast) { 
     440                                                        push(@{($prog->{credits}->{director})},$cast); 
     441                                                        Shepherd::Common::log("   added director '$cast'") if (defined $opt->{debug}); 
     442                                                } 
     443                                        } 
     444                                } 
     445 
     446                                # Writer 
     447                                if ((defined $episode_data->{Writer}) && ($episode_data->{Writer} ne "") && 
     448                                    (defined $prog->{credits}) && (defined $prog->{credits}->{writer})) { 
     449                                        foreach my $cast (split(/[\|,]/,$episode_data->{Writer})) { 
     450                                                $cast =~ s/(^\s+|\s+$)//g; 
     451                                                next if ($cast eq ""); 
     452                                                my $found_cast = 0; 
     453                                                foreach my $w (@{($prog->{credits}->{writer})}) { 
     454                                                        $found_cast++ if (lc($cast) eq lc($w)); 
     455                                                } 
     456                                                if (!$found_cast) { 
     457                                                        push(@{($prog->{credits}->{writer})},$cast); 
     458                                                        Shepherd::Common::log("   added writer '$cast'") if (defined $opt->{debug}); 
     459                                                } 
     460                                        } 
     461                                } 
    346462                        } 
    347463 
     
    351467                                $prog->{desc}->[0]->[0] .= "\n\n" if ($prog->{desc}->[0]->[0] ne ""); 
    352468                                $prog->{desc}->[0]->[0] .= "TheTVDB.com augmented data:".$desc; 
     469                                Shepherd::Common::log("   augmented description") if (defined $opt->{debug}); 
    353470                        } 
    354471 
  • status

    r729 r730  
    1616reconciler      reconciler_mk2      0.26 
    1717postprocessor   imdb_augment_data   0.19 
    18 postprocessor   tvdb_augment_data   0.01 
     18postprocessor   tvdb_augment_data   0.02 
    1919postprocessor   flag_aus_hdtv       0.17 
    2020postprocessor   augment_timezone    0.13