Skip to content

Commit

Permalink
Añadidos métodos find
Browse files Browse the repository at this point in the history
- Añadidos métodos find [movies, tvShow, season, episode, person].
- Correcciones menores.
  • Loading branch information
alvaro-octal committed Mar 2, 2015
1 parent e9301de commit 02b0311
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public function getTagline() {
return $this->_data['tagline'];
}

/**
* Get the Movie's overview
*
* @return string
*/
public function getOverview() {
return $this->_data['overview'];
}

/**
* Get the Movie's Poster
*
Expand Down
11 changes: 11 additions & 0 deletions examples/moviesExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@
echo ' </ul></li>';
echo '</ul>...';
echo '<img src="'. $tmdb->getImageURL('w185') . $company->getLogo() .'"/></li>';

// 9. Find Movie by IMDB id

echo '<li><a id="findMovie"><h3>Find Movie by IMDB id</h3></a><ul>';

$movies = $tmdb->findMovie('tt0133093');
foreach($movies as $movie){
echo '<li>'. $movie->getTitle() .' (<a href="https://www.themoviedb.org/movie/'. $movie->getID() .'">'. $movie->getID() .'</a>)</li>';
}

echo '</ul></li><hr>';
?>
</body>
</html>
10 changes: 10 additions & 0 deletions examples/personsExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@
echo '<li>'. $person->getName() .' (<a href="https://www.themoviedb.org/person/'. $person->getID() .'">'. $person->getID() .'</a>)</li>';
}
echo '</ol></li><hr>';

// 6. Find Person by external ID

echo '<li><a id="findPerson"><h3>Find person by external ID</h3></a><ul>';

$persons = $tmdb->findPerson('nm0000652');
foreach($persons as $person){
echo '<li>'. $person->getName() .' (<a href="https://www.themoviedb.org/person/'. $person->getID() .'">'. $person->getID() .'</a>)</li>';
}
echo '</ul></li><hr>';
?>
</body>
</html>
10 changes: 10 additions & 0 deletions examples/tvshowsExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
echo ' <li>Vote Average: '. $episode->getVoteAverage() .'</li>';
echo ' <li>Vode Count: '. $episode->getVoteCount() .'</li>';
echo ' </ul></ul>...<hr>';

// 5. Find TVShow by external ID

echo '<li><a id="findPerson"><h3>Find TVShow by external ID</h3></a><ul>';

$tvShows = $tmdb->findTVShow('tt3032476');
foreach($tvShows as $tvShow){
echo '<li>'. $tvShow->getName() .' (<a href="https://www.themoviedb.org/tv/'. $tvShow->getID() .'">'. $tvShow->getID() .'</a>)</li>';
}
echo '</ul></li><hr>';
?>
</body>
</html>
89 changes: 89 additions & 0 deletions tmdb-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,5 +609,94 @@ public function getPopularPersons($page = 1) {

return $persons;
}

//------------------------------------------------------------------------------
// Find
//------------------------------------------------------------------------------

/**
* Get a Movie by an external ID (f.e.: imdb)
*
* @return Movie[]
*/
public function findMovie($movieID, $externalSource = 'imdb_id'){
$movies = array();

$result = $this->_call('find/' . $movieID, 'external_source=' . $externalSource);

foreach ($result['movie_results'] as $data) {
$movies[] = new Movie($data);
}

return $movies;
}

/**
* Get a Person by an external ID (f.e.: imdb)
*
* @return Person[]
*/
public function findPerson($personID, $externalSource = 'imdb_id'){
$persons = array();

$result = $this->_call('find/' . $personID, 'external_source=' . $externalSource);

foreach ($result['person_results'] as $data) {
$persons[] = new Person($data);
}

return $persons;
}

/**
* Get a TVShow by an external ID (f.e.: imdb)
*
* @return TVShow[]
*/
public function findTVShow($tvShowID, $externalSource = 'imdb_id'){
$tvShows = array();

$result = $this->_call('find/' . $tvShowID, 'external_source=' . $externalSource);

foreach ($result['tv_results'] as $data) {
$tvShows[] = new TVShow($data);
}

return $tvShows;
}

/**
* Get a Season by an external ID (f.e.: imdb)
*
* @return Season[]
*/
public function findSeason($seasonID, $externalSource = 'tvdb_id'){
$seasons = array();

$result = $this->_call('find/' . $seasonID, 'external_source=' . $externalSource);

foreach ($result['tv_season_results'] as $data) {
$seasons[] = new Season($data);
}

return $seasons;
}

/**
* Get a Episode by an external ID (f.e.: imdb)
*
* @return Episode[]
*/
public function findEpisode($episodeID, $externalSource = 'imdb_id'){
$episodes = array();

$result = $this->_call('find/' . $episodeID, 'external_source=' . $externalSource);

foreach ($result['tv_episode_results'] as $data) {
$episodes[] = new Episode($data);
}

return $episodes;
}
}
?>

0 comments on commit 02b0311

Please sign in to comment.