<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getAlternativeTitles(1396);
var_dump($result);
Example #2
0
 /**
  * get_metadata
  * Returns song metadata for what we're passed in.
  */
 public function get_metadata($gather_types, $media_info)
 {
     debug_event('tmdb', 'Getting metadata from Tmdb...', '5');
     // TVShow / Movie metadata only
     if (!in_array('tvshow', $gather_types) && !in_array('movie', $gather_types)) {
         debug_event('tmdb', 'Not a valid media type, skipped.', '5');
         return null;
     }
     try {
         $token = new \Tmdb\ApiToken($this->api_key);
         $client = new \Tmdb\Client($token);
         $configRepository = new \Tmdb\Repository\ConfigurationRepository($client);
         $config = $configRepository->load();
         $imageHelper = new \Tmdb\Helper\ImageHelper($config);
         $title = $media_info['original_name'] ?: $media_info['title'];
         $results = array();
         if (in_array('movie', $gather_types)) {
             if (!empty($title)) {
                 $apires = $client->getSearchApi()->searchMovies($title);
                 if (count($apires['results']) > 0) {
                     $results['tmdb_id'] = $apires['results'][0]['id'];
                     $release = $client->getMoviesApi()->getMovie($results['tmdb_id']);
                     $results['imdb_id'] = $release['imdb_id'];
                     $results['original_name'] = $release['original_title'];
                     if (!empty($release['release_date'])) {
                         $results['release_date'] = strtotime($release['release_date']);
                         $results['year'] = date("Y", $results['release_date']);
                         // Production year shouldn't be the release date
                     }
                     if ($release['poster_path']) {
                         $results['art'] = $imageHelper->getUrl($release['poster_path']);
                     }
                     if ($release['backdrop_path']) {
                         $results['background_art'] = $imageHelper->getUrl($release['backdrop_path']);
                     }
                     $results['genre'] = self::get_genres($release);
                 }
             }
         }
         if (in_array('tvshow', $gather_types)) {
             if (!empty($media_info['tvshow'])) {
                 $apires = $client->getSearchApi()->searchTv($media_info['tvshow']);
                 if (count($apires['results']) > 0) {
                     // Get first match
                     $results['tmdb_tvshow_id'] = $apires['results'][0]['id'];
                     $release = $client->getTvApi()->getTvshow($results['tmdb_tvshow_id']);
                     $results['tvshow'] = $release['original_name'];
                     if (!empty($release['first_air_date'])) {
                         $results['tvshow_year'] = date("Y", strtotime($release['first_air_date']));
                     }
                     if ($release['poster_path']) {
                         $results['tvshow_art'] = $imageHelper->getUrl($release['poster_path']);
                     }
                     if ($release['backdrop_path']) {
                         $results['tvshow_background_art'] = $imageHelper->getUrl($release['backdrop_path']);
                     }
                     $results['genre'] = self::get_genres($release);
                     if ($media_info['tvshow_season']) {
                         $release = $client->getTvSeasonApi()->getSeason($results['tmdb_tvshow_id'], $media_info['tvshow_season']);
                         if ($release['id']) {
                             if ($release['poster_path']) {
                                 $results['tvshow_season_art'] = $imageHelper->getUrl($release['poster_path']);
                             }
                             if ($media_info['tvshow_episode']) {
                                 $release = $client->getTvEpisodeApi()->getEpisode($results['tmdb_tvshow_id'], $media_info['tvshow_season'], $media_info['tvshow_episode']);
                                 if ($release['id']) {
                                     $results['tmdb_id'] = $release['id'];
                                     $results['tvshow_season'] = $release['season_number'];
                                     $results['tvshow_episode'] = $release['episode_number'];
                                     $results['original_name'] = $release['name'];
                                     if (!empty($release['air_date'])) {
                                         $results['release_date'] = strtotime($release['release_date']);
                                         $results['year'] = date("Y", $results['release_date']);
                                     }
                                     $results['description'] = $release['overview'];
                                     if ($release['still_path']) {
                                         $results['art'] = $imageHelper->getUrl($release['still_path']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         debug_event('tmdb', 'Error getting metadata: ' . $e->getMessage(), '1');
     }
     return $results;
 }
Example #3
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getPopular();
var_dump($result);
Example #4
0
File: videos.php Project: n10ty/api
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getVideos(1396);
var_dump($result);
Example #5
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getCredits(1396);
var_dump($result);
Example #6
0
File: latest.php Project: n10ty/api
<?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 <*****@*****.**>
 * @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);
$tvShow = $client->getTvApi()->getLatest();
var_dump($tvShow);
Example #7
0
File: show.php Project: n10ty/api
<?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 <*****@*****.**>
 * @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);
$tvShow = $client->getTvApi()->getTvshow(1396);
var_dump($tvShow);
Example #8
0
File: rate.php Project: n10ty/api
<?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 <*****@*****.**>
 * @copyright (c) 2013, Michael Roterman
 * @version 0.0.1
 */
ini_set('display_errors', 'On');
require_once '../../../../vendor/autoload.php';
require_once '../../../../apikey.php';
$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);
$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN);
$client->setSessionToken($sessionToken);
$result = $client->getTvApi()->rateTvShow(1396, 9.5);
var_dump($result);
<?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 <*****@*****.**>
 * @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);
$contentRatings = $client->getTvApi()->getcontentRatings(1396);
var_dump($contentRatings);
Example #10
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getAiringToday();
var_dump($result);
Example #11
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getTranslations(1396);
var_dump($result);
Example #12
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getTopRated();
var_dump($result);
Example #13
0
File: images.php Project: n10ty/api
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getImages(1396);
var_dump($result);
Example #14
0
<?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 <*****@*****.**>
 * @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);
$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN);
$client->setSessionToken($sessionToken);
$result = $client->getTvApi()->getAccountStates(1396);
var_dump($result);
Example #15
0
<?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 <*****@*****.**>
 * @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);
$result = $client->getTvApi()->getOnTheAir();
var_dump($result);