예제 #1
0
function getFeed($feed_url, $type)
{
    // Type: Movie(0), TV(1), Animated(2)
    $content = file_get_contents($feed_url);
    $x = new SimpleXmlElement($content);
    $token = new \Tmdb\ApiToken('1e5387b55fe12efeb19db53ea9ca88a1');
    $client = new \Tmdb\Client($token);
    if ($type != 1) {
        $all_genres = $client->getGenresApi()->getGenres();
        $all_genres_ids = array();
        foreach ($all_genres['genres'] as $genre) {
            array_push($all_genres_ids, $genre['id']);
        }
        $current_ids = array();
        foreach ($x->channel->item as $entry) {
            /* @@ Modification for TMDB API @@ */
            $movie_title = $entry->title;
            $title = modifyTitle($movie_title);
            $result = $client->getSearchApi()->searchMovies($title);
            $movie = array_values($result)[1][0];
            /* @@ Check if result is found from TMDB API @@ */
            if (count($movie) > 0) {
                if (!in_array(intval($movie['id']), $current_ids)) {
                    array_push($current_ids, intval($movie['id']));
                } else {
                    continue;
                }
                /* @@ Title @@ */
                $original_title = shortenText($movie['original_title'], 40);
                /* @@ Plot (overview) @@ */
                $plot = shortenText($movie['overview'], 285);
                /* @@ Release year @@ */
                $released_year = substr($movie['release_date'], 0, 4);
                /* @@ Release year @@ */
                $genres = $movie['genre_ids'];
                $genre_string = getGenreString($genres, $all_genres_ids, $all_genres);
                $poster_url = "http://image.tmdb.org/t/p/w500/" . $movie['poster_path'];
                $backdrop_url = "http://image.tmdb.org/t/p/w500" . $movie['backdrop_path'];
                $content_url = "https://www.themoviedb.org/movie/" . $movie['id'];
                renderTable($original_title, $plot, $released_year, $genre_string, $poster_url, $backdrop_url, $content_url, $entry->link);
            } else {
                if ($type != 2) {
                    // Teiknimyndir eru oft á íslensku og þ.a.l. ekki á TMDB
                    $plot = "Ekki fundust upplýsingar um þessa mynd.<br>Titill hennar gæti verið stafsettur vitlaust.<br>Einnig gæti verið að þetta sé sjónvarsþáttur.";
                    renderTable($entry->title, $plot, null, null, null, null, null, $entry->link);
                }
            }
        }
    } else {
        // TV SHOWS
        foreach ($x->channel->item as $entry) {
            $tv_show_title = $entry->title;
            $tv_show_title = modifyTvShowTitle($tv_show_title);
            $result = $client->getSearchApi()->searchTv($tv_show_title);
            $tv_show = array_values($result)[1][0];
            if (count($tv_show) > 0) {
                $tv_show_title = $tv_show['name'];
                $tv_show_title .= ' ' . getEpisodeNumber($entry->title);
                $plot = shortenText($tv_show['overview'], 300);
                $released_year = substr($tv_show['first_air_date'], 0, 4);
                $genres = $tv_show['genre_ids'];
                $genre_string = getGenreString($genres, $all_genres_ids, $all_genres);
                $poster_url = "http://image.tmdb.org/t/p/w500/" . $tv_show['poster_path'];
                $backdrop_url = "http://image.tmdb.org/t/p/w500" . $tv_show['backdrop_path'];
                $content_url = "https://www.themoviedb.org/tv/" . $tv_show['id'];
                renderTable($tv_show_title, $plot, $released_year, $genre_string, $poster_url, $backdrop_url, $content_url, $entry->link);
            }
        }
    }
}
예제 #2
0
파일: movies.php 프로젝트: 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);
$genres = $client->getGenresApi()->getMovies(18);
var_dump($genres);
예제 #3
0
파일: all.php 프로젝트: 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);
$genres = $client->getGenresApi()->getGenres();
var_dump($genres);
예제 #4
0
파일: get.php 프로젝트: 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);
$genre = $client->getGenresApi()->getGenre(28);
var_dump($genre);