Ticket #6467: tmdb.tmdbid.3.patch

File tmdb.tmdbid.3.patch, 3.7 KB (added by Raymond Wagner <raymond@…>, 3 years ago)
  • mythplugins/mythvideo/mythvideo/scripts/tmdb.pl

     
    117117 
    118118    # get the search results page via Movie.imdbLookup 
    119119    my ($rc, $response) = 
    120         TMDBAPIRequest('Movie.imdbLookup', {'imdb_id' => "tt$movieid"}); 
     120        TMDBAPIRequest('Movie.getInfo' {'id' => "$movieid"}); 
    121121 
    122122    if (!defined $response) { 
    123123        die "Unable to contact themoviedb.org while retrieving ". 
     
    126126 
    127127    my $xs = new XML::Simple(SuppressEmpty => '', ForceArray => ['movie'], 
    128128        KeyAttr => []); 
    129     my $xml = $xs->XMLin($response); 
    130  
    131     if ($xml->{"opensearch:totalResults"} > 0) { 
    132         # now get the movie data via Movie.getInfo, Movie.imdbLookup does not 
    133         # provide us all the data 
    134         my $tmdbid = $xml->{moviematches}->{movie}->[0]->{id}; 
    135         my ($rc, $response) = 
    136             TMDBAPIRequest('Movie.getInfo', {'id' => $tmdbid}); 
    137  
    138         if (!defined $response) { 
    139             die "Unable to contact themoviedb.org while retrieving ". 
    140                 "movie data, stopped"; 
    141         } 
    142  
    143         $xml = $xs->XMLin($response, 
     129    my $xml = $xs->XMLin($response, 
    144130            ForceArray => ['category', 'production_countries', 'person'], 
    145131            KeyAttr => ['key', 'id']); 
    146132 
     133    if ($xml->{"opensearch:totalResults"} > 0) { 
    147134        my $movie = $xml->{moviematches}->{movie}; 
    148135        my $title       = $movie->{title}; 
    149136        my $releasedate = $movie->{release}; 
     
    244231 
    245232    # get the search results  page 
    246233    my ($rc, $response) = 
    247         TMDBAPIRequest('Movie.imdbLookup', {'imdb_id' => "tt$movieid"}); 
     234        TMDBAPIRequest('Movie.getInfo', {'id' => "$movieid"}); 
    248235 
    249236    if (!defined $response) { 
    250237        die "Unable to contact themoviedb.org while retrieving ". 
     
    272259 
    273260    # get the search results page via Movie.imdbLookup 
    274261    my ($rc, $response) = 
    275         TMDBAPIRequest('Movie.imdbLookup', {'imdb_id' => "tt$movieid"}); 
     262        TMDBAPIRequest('Movie.getInfo', {'id' => "$movieid"}); 
    276263 
    277264    if (!defined $response) { 
    278265        die "Unable to contact themoviedb.org while retrieving ". 
     
    281268 
    282269    my $xs = new XML::Simple(SuppressEmpty => '', ForceArray => ['movie'], 
    283270        KeyAttr => []); 
    284     my $xml = $xs->XMLin($response); 
     271    my $xml = $xs->XMLin($response, ForceArray=> ['backdrop'], KeyAttr => ['key', 'id']); 
    285272 
    286273    if ($xml->{"opensearch:totalResults"} > 0) { 
    287         # now get the movie data via Movie.getInfo, Movie.imdbLookup does not 
    288         # provide us all the data 
    289         my $tmdbid = $xml->{moviematches}{movie}[0]{id}; 
    290  
    291         my ($rc, $response) = 
    292             TMDBAPIRequest('Movie.getInfo', {'id' => $tmdbid}); 
    293  
    294         if (!defined $response) { 
    295             die "Unable to contact themoviedb.org while retrieving ". 
    296                 "movie backdrop, stopped"; 
    297         } 
    298  
    299         $xml = XMLin($response, ForceArray=> ['backdrop'], KeyAttr => ['key', 'id']); 
    300  
    301274        foreach my $backdrop (@{$xml->{moviematches}->{movie}->{backdrop}}) { 
    302275            # print "$backdrop->{content}\n"; 
    303276 
     
    342315                next; 
    343316            } 
    344317 
    345             my $movienum  = $movie->{imdb}; 
     318            my $movienum  = $movie->{id}; 
    346319            my $moviename = $movie->{title}; 
    347320            my $release   = $movie->{release}; 
    348321            my $movieyear = 0; 
     
    352325            } 
    353326 
    354327            if ($movienum) { 
    355                 $movienum =~ s/^tt//; 
    356328                my $entry = $movienum . ":" . $moviename; 
    357329                if ($release) { 
    358330                    $entry = $entry . " (". $movieyear . ")";