Skip to content

Commit

Permalink
Fixing TV Shows / Seasons / Episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 9, 2014
1 parent bf1d472 commit 00f58cb
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 12 deletions.
22 changes: 22 additions & 0 deletions examples/tv/model/episode/credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvEpisodeRepository($client);
$tvShow = $repository->getCredits(1396, 1, 1);

var_dump($tvShow);
22 changes: 22 additions & 0 deletions examples/tv/model/episode/external_ids.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvEpisodeRepository($client);
$tvShow = $repository->getExternalIds(1396, 1, 1);

var_dump($tvShow);
22 changes: 22 additions & 0 deletions examples/tv/model/episode/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvEpisodeRepository($client);
$tvShow = $repository->getImages(1396, 1, 1);

var_dump($tvShow);
22 changes: 22 additions & 0 deletions examples/tv/model/season/credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvSeasonRepository($client);
$tvShow = $repository->getCredits(1396, 1);

var_dump($tvShow);
22 changes: 22 additions & 0 deletions examples/tv/model/season/external_ids.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvSeasonRepository($client);
$tvShow = $repository->getExternalIds(1396, 1);

var_dump($tvShow);
22 changes: 22 additions & 0 deletions examples/tv/model/season/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../../vendor/autoload.php');
require_once('../../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\TvSeasonRepository($client);
$tvShow = $repository->getImages(1396, 1);

var_dump($tvShow);
6 changes: 3 additions & 3 deletions lib/Tmdb/Api/TvEpisode.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getEpisode($tvshow_id, $season_number, $episode_number, array $p
* @param array $headers
* @return mixed
*/
public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
public function getCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
}
Expand All @@ -55,7 +55,7 @@ public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, a
* @param array $headers
* @return mixed
*/
public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
public function getExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
}
Expand All @@ -70,7 +70,7 @@ public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_numbe
* @param array $headers
* @return mixed
*/
public function getEpisodeImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
public function getImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $parameters, $headers);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Api/TvSeason.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getSeason($tvshow_id, $season_number, array $parameters = array(
* @param array $headers
* @return mixed
*/
public function getSeasonCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
public function getCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/credits', $tvshow_id, $season_number), $parameters, $headers);
}
Expand All @@ -52,7 +52,7 @@ public function getSeasonCredits($tvshow_id, $season_number, array $parameters =
* @param array $headers
* @return mixed
*/
public function getSeasonExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
public function getExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $parameters, $headers);
}
Expand All @@ -66,7 +66,7 @@ public function getSeasonExternalIds($tvshow_id, $season_number, array $paramete
* @param array $headers
* @return mixed
*/
public function getSeasonImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
public function getImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array())
{
return $this->get(sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers);
}
Expand Down
56 changes: 56 additions & 0 deletions lib/Tmdb/Repository/TvEpisodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,62 @@ public function load($tvShow, $season, $episode, array $parameters = array(), ar
return $this->getFactory()->create($data);
}

/**
* Get the cast & crew information about a TV series.
*
* Just like the website, we pull this information from the last season of the series.
*
* @param $id
* @param $season
* @param $episode
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getCredits($id, $season, $episode, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getCredits($id, $season, $episode, $this->parseQueryParameters($parameters), $headers);
$episode = $this->getFactory()->create(array('credits' => $data));

return $episode->getCredits();
}

/**
* Get the external ids that we have stored for a TV series.
*
* @param $id
* @param $season
* @param $episode
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getExternalIds($id, $season, $episode, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getExternalIds($id, $season, $episode, $this->parseQueryParameters($parameters), $headers);
$episode = $this->getFactory()->create(array('external_ids' => $data));

return $episode->getExternalIds();
}

/**
* Get the images (posters and backdrops) for a TV series.
*
* @param $id
* @param $season
* @param $episode
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getImages($id, $season, $episode, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getImages($id, $season, $episode, $this->parseQueryParameters($parameters), $headers);
$episode = $this->getFactory()->create(array('images' => $data));

return $episode->getImages();
}

/**
* Return the Seasons API Class
*
Expand Down
54 changes: 54 additions & 0 deletions lib/Tmdb/Repository/TvSeasonRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,60 @@ public function load($tvShow, $season, array $parameters = array(), array $heade
return $this->getFactory()->create($data);
}


/**
* Get the cast & crew information about a TV series.
*
* Just like the website, we pull this information from the last season of the series.
*
* @param $id
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getCredits($id, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getCredits($id, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('credits' => $data));

return $season->getCredits();
}

/**
* Get the external ids that we have stored for a TV series.
*
* @param $id
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getExternalIds($id, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getExternalIds($id, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('external_ids' => $data));

return $season->getExternalIds();
}

/**
* Get the images (posters and backdrops) for a TV series.
*
* @param $id
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getImages($id, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getImages($id, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('images' => $data));

return $season->getImages();
}

/**
* Return the Seasons API Class
*
Expand Down
6 changes: 3 additions & 3 deletions test/Tmdb/Tests/Api/TvEpisodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function shouldGetEpisodeCredits()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/credits');

$api->getEpisodeCredits(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
$api->getCredits(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
}

/**
Expand All @@ -54,7 +54,7 @@ public function shouldGetEpisodeExternalIds()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/external_ids');

$api->getEpisodeExternalIds(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
$api->getExternalIds(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
}

/**
Expand All @@ -67,7 +67,7 @@ public function shouldGetEpisodeImages()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/images');

$api->getEpisodeImages(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
$api->getImages(self::TV_ID, self::SEASON_ID, self::EPISODE_ID);
}

protected function getApiClass() {
Expand Down
6 changes: 3 additions & 3 deletions test/Tmdb/Tests/Api/TvSeasonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function shouldGetSeasonCredits()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/credits');

$api->getSeasonCredits(self::TV_ID, self::SEASON_ID);
$api->getCredits(self::TV_ID, self::SEASON_ID);
}

/**
Expand All @@ -53,7 +53,7 @@ public function shouldGetSeasonExternalIds()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/external_ids');

$api->getSeasonExternalIds(self::TV_ID, self::SEASON_ID);
$api->getExternalIds(self::TV_ID, self::SEASON_ID);
}

/**
Expand All @@ -66,7 +66,7 @@ public function shouldGetSeasonImages()
->method('get')
->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/images');

$api->getSeasonImages(self::TV_ID, self::SEASON_ID);
$api->getImages(self::TV_ID, self::SEASON_ID);
}

protected function getApiClass() {
Expand Down

0 comments on commit 00f58cb

Please sign in to comment.