Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #70: implemented getTrailers() for TVShows and added example; #71

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configuration/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
$cnf['debug'] = false;

// Data Return Configuration - Manipulate if you want to tune your results
$cnf['appender']['movie'] = array('trailers', 'images', 'credits', 'translations', 'reviews');
$cnf['appender']['tvshow'] = array('trailers', 'images', 'credits', 'translations', 'keywords');
$cnf['appender']['movie'] = array('trailers', 'videos', 'images', 'credits', 'translations', 'reviews');
$cnf['appender']['tvshow'] = array('trailers', 'videos', 'images', 'credits', 'translations', 'keywords');
$cnf['appender']['season'] = array('trailers', 'images', 'credits', 'translations');
$cnf['appender']['episode'] = array('trailers', 'images', 'credits', 'translations');
$cnf['appender']['person'] = array('movie_credits', 'tv_credits', 'images');
Expand Down
10 changes: 10 additions & 0 deletions controller/classes/data/Season.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function getEpisode($numEpisode) {
return new Episode($this->_data['episodes'][$numEpisode]);
}

/**
* Get a Seasons's Episode Count
*
* @param int $numEpisode The episode number
* @return int
*/
public function getEpisodeCount() {
return $this->_data['episode_count'];
}

/**
* Get the Season's Episodes
*
Expand Down
34 changes: 34 additions & 0 deletions controller/classes/data/TVShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,40 @@ public function getSeasons() {
return $seasons;
}

public function getVideos() {
$videos = $this->_data['videos'];

if (array_key_exists('results', $videos)) {
return $videos['results'];
}

return [];
}

/**
* Get the TVShow's trailers
*
* @return array
*/
public function getTrailers() {
$trailers = [];
$videos = $this->getVideos();

foreach($videos as $video) {
if($video['type'] !== 'Trailer') {
continue;
}

if($video['site'] !== 'YouTube'){
continue;
}

$trailers[] = $video;
}

return $trailers;
}

/**
* Get the TVShow's Backdrop
*
Expand Down
15 changes: 12 additions & 3 deletions examples/tvshows/infoTVShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@
'</li>
<li>Number of Seasons: ' .
$tvShow->getNumSeasons() .
'</li>
<li>Seasons:
'</li>';

$trailers = $tvShow->getTrailers();
echo '<li>Trailers:</li>';
echo '<ul>';
foreach ($trailers as $trailer) {
echo '<li>Trailer '.$trailer['name'].': <a href="https://www.youtube.com/watch?v=' . $trailer['key'] . '">link</a></li>';
}
echo '</ul>';

echo '<li>Seasons:
<ul>';
$seasons = $tvShow->getSeasons();
foreach ($seasons as $season) {
echo ' <li><a href="https://www.themoviedb.org/tv/season/' .
$season->getID() .
'">Season ' .
$season->getSeasonNumber() .
'</a></li>';
'</a> EpisodeCount: '.$season->getEpisodeCount().'</li>';
}
echo ' </ul>
</li>
Expand Down