Автор: Jérôme Poskin (moinax@gmail.com)
Пример #1
0
 public function tv($id)
 {
     $this->validateKeys(['tvdb' => $id]);
     $key = 'tvdb' . $id;
     $result = $this->cache($key);
     if (!$result) {
         $result = $this->tvdb_api->getSerieEpisodes($id);
         $this->cache($key, $result);
     }
     return $this->formatTv($result);
 }
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     app()->bind('TvDb', function () {
         $apiKey = env('TVDB_APIKEY', null);
         if (!$apiKey) {
             throw new \Exception('You need a TvDb API key.');
         }
         $cache = new FilesystemCache(storage_path() . '/TvDbCache');
         $ttl = 60 * 60 * 24;
         $httpClient = new CacheClient($cache, $ttl);
         $tvdb = new Client("http://thetvdb.com", $apiKey);
         $tvdb->setHttpClient($httpClient);
         $tvdb->setJsonDateFormat('d-m-Y');
         $tvdb->setDefaultLanguage('nl');
         return $tvdb;
     });
 }
Пример #3
0
 /**
  * @param      $baseUrl
  * @param      $apiKey
  * @param null $cachePath
  * @param null $cacheTtl
  */
 public function __construct($baseUrl, $apiKey, $cachePath = null, $cacheTtl = null)
 {
     parent::__construct($baseUrl, $apiKey);
     if ($cachePath != null && is_string($cachePath)) {
         // Set default cache TTL to one week.
         $cacheTtl != null && is_int($cacheTtl) ? $cacheTtl : 86400 * 7;
         // Create cache client and assign it to TvDb-client
         $cache = new FilesystemCache($cachePath);
         $httpClient = new CacheClient($cache, $cacheTtl);
         $this->setHttpClient($httpClient);
     }
 }
Пример #4
0
require_once '../lib_database.php';
require_once '../lib_directory.php';
require_once '../lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
#####################################################################
$query = $_POST['q'];
$theme = $options->get('theme');
$basedir = $options->get('base_directory');
$themepath = $basedir . 'frontend/themes/' . $theme;
$partial = $themepath . '/partials/' . $_POST['p'] . '.php';
$partial_code = file_get_contents($partial);
$helper->log($query);
$data = $tvdb->getSeries($query, 'de');
$values = array();
foreach ($data as $show) {
    $values['name'] = $show->name;
    $values['description'] = $show->overview;
    $url = "http://thetvdb.com/banners/_cache/" . $show->banner;
Пример #5
0
require_once '../lib_database.php';
require_once '../lib_mediaobject.php';
require_once '../lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
####################################################################
$method = $_POST['m'];
$paramString = $_POST['p'];
$params = preg_split('/\\*/', $paramString);
call_user_func($method, $params[0]);
function add_show($showName)
{
    global $helper, $db, $options, $tvdb;
    # CHECK IF SHOW EXISTS
    if (!$db->load_objects_by_column('tv_shows', 'show_name', $showName)) {
        $helper->log('not found');
        $img_basedir = $options->get('banner_directory');
        $tvdb_url = $options->get('tvdb_url');
        $serverTime = $tvdb->getServerTime();
 public function getEpisodeById($episodeId)
 {
     $episode = $this->tvDb->getEpisodeById($episodeId);
     return JsonResponse::create($episode);
 }
Пример #7
0
require_once 'lib/lib_database.php';
require_once 'lib/lib_directory.php';
require_once 'lib/lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
#####################################################################
$shows = $db->load_all_objects('tv_shows');
foreach ($shows as $show) {
    $data = $tvdb->getSerieEpisodes($show['tvdb_id'], 'de');
    foreach ($data['episodes'] as $episode) {
        $db_episode = $db->load_episode($show['id'], $episode->season, $episode->number);
        if (!$db_episode) {
            $new_episode = array();
            $new_episode['show_id'] = $show['id'];
            $new_episode['season_num'] = $episode->season;
            $new_episode['episode_num'] = $episode->number;
            $new_episode['episode_name'] = $episode->name;
            $new_episode['airdate'] = $episode->firstAired;
            $db->insert($new_episode, 'tv_files');
Пример #8
0
require_once 'lib/lib_database.php';
require_once 'lib/lib_directory.php';
require_once 'lib/lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
#####################################################################
$episodes = $db->load_objects_by_sql('SELECT s.tvdb_id, f.id, f.filename FROM tv_files f, tv_shows s WHERE f.show_id = s.id');
foreach ($episodes as $episode) {
    # FIRST VERSION: EXPECT NAME TO BE LIKE
    # <SHOWNAME> - <EPISODE SXXEYY> - <OPTIONAL EPISODE-TITLE>.<EXTENSION>
    # SIMPLE / DIRTY
    # EXTRACT HERE AND CREATE METHOD FOR THAT.
    list($show_name, $seasonepisode, $episode_title) = preg_split('/ - /', $episode['filename']);
    $season = intval(substr($seasonepisode, 1, 2));
    $episode_num = intval(substr($seasonepisode, 4, 2));
    $file = $db->load_object_by_id('tv_files', $episode['id']);
    $data = $tvdb->getEpisode($episode['tvdb_id'], $season, $episode_num, 'de');
    $file['season_num'] = $season;
    $file['episode_num'] = $episode_num;
Пример #9
0
<?php

include __DIR__ . '/settings.php';
include __DIR__ . '/../src/Moinax/TvDb/Http/HttpClient.php';
include __DIR__ . '/../src/Moinax/TvDb/Http/CurlClient.php';
include __DIR__ . '/../src/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../src/Moinax/TvDb/Client.php';
include __DIR__ . '/../src/Moinax/TvDb/Serie.php';
include __DIR__ . '/../src/Moinax/TvDb/Banner.php';
include __DIR__ . '/../src/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
// Search for a show
$data = $tvdb->getSeries('Walking Dead');
// Use the first show found and get the S01E01 episode
$episode = $tvdb->getEpisode($data[0]->id, 1, 1, 'en');
var_dump($episode);
/*$date = new \DateTime('-1 day');
$data = $tvdb->getUpdates($date->getTimestamp());
var_dump($data);
*/
/*
// Get full series and episode info
$episodes = $tvdb->getSerieEpisodes(153021, 'fr', Client::FORMAT_ZIP);
var_dump($episodes["episodes"]);
printf ("(%d Episodes)\n", count($episodes["episodes"]));
*/
Пример #10
0
require_once 'lib/lib_database.php';
require_once 'lib/lib_directory.php';
require_once 'lib/lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
#####################################################################
$img_basedir = $options->get('banner_directory');
$tvdb_url = $options->get('tvdb_url');
$db_images = $db->load_all_objects('tv_shows');
foreach ($db_images as $image) {
    $banner = $tvdb->getBanners($image['tvdb_id'], 'poster');
    $image['poster'] = $banner[0]->path;
    $db->update($image, 'tv_shows');
    echo ".";
    $image_path = $img_basedir . $image['poster'];
    echo $image_path . "\n";
    if (!file_exists($image_path)) {
        $img_url = $tvdb_url . '/banners/_cache/' . $image['poster'];
        echo $img_url . "\n";
Пример #11
0
<?php

include __DIR__ . '/settings.php';
include __DIR__ . '/../src/Moinax/TvDb/Http/HttpClient.php';
include __DIR__ . '/../src/Moinax/TvDb/Http/CurlClient.php';
include __DIR__ . '/../src/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../src/Moinax/TvDb/Client.php';
include __DIR__ . '/../src/Moinax/TvDb/Serie.php';
include __DIR__ . '/../src/Moinax/TvDb/Banner.php';
include __DIR__ . '/../src/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
// Search for a show
$data = $tvdb->getSeries('Walking Dead');
// Use the first show found and get the S01E01 episode
$episode = $tvdb->getEpisode($data[0]->id, 1, 1, 'en');
var_dump($episode);
// format the episode as JSON
$tvdb->setJsonDateFormat(TVDB_JSON_DATE_FORMAT);
$tvdb->setJsonTimeFormat(TVDB_JSON_TIME_FORMAT);
var_dump(json_encode($episode));
/*$date = new \DateTime('-1 day');
$data = $tvdb->getUpdates($date->getTimestamp());
var_dump($data);
*/
/*
// Get full series and episode info
$episodes = $tvdb->getSerieEpisodes(153021, 'fr', Client::FORMAT_ZIP);
var_dump($episodes["episodes"]);
printf ("(%d Episodes)\n", count($episodes["episodes"]));
Пример #12
0
require_once 'lib/lib_database.php';
require_once 'lib/lib_directory.php';
require_once 'lib/lib_options.php';
$helper = new LibHelper();
$db = new LibDatabase($dbs);
$options = new LibOptions();
# 3RD PARTY MODULE SETUP: TVDB #####################################
define('TVDB_URL', $options->get('tvdb_url'));
define('TVDB_API_KEY', $options->get('tvdb_api_key'));
include __DIR__ . '/../3rd_party/Moinax/TvDb/CurlException.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Client.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Serie.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Banner.php';
include __DIR__ . '/../3rd_party/Moinax/TvDb/Episode.php';
use Moinax\TvDb\Client;
$tvdb = new Client(TVDB_URL, TVDB_API_KEY);
$serverTime = $tvdb->getServerTime();
#####################################################################
$files = $db->get_incomplete_shows();
$i = 0;
foreach ($files as $file) {
    # FIRST VERSION: EXPECT NAME TO BE LIKE
    # <SHOWNAME> - <EPISODE SXXEYY> - <OPTIONAL EPISODE-TITLE>.<EXTENSION>
    # SIMPLE / DIRTY
    list($show_name, $episode, $episode_title) = preg_split('/ - /', $file['filename']);
    $episode_title = substr($episode_title, 0, -4);
    $media_obj = $db->load_object_by_column('tv_shows', 'show_name', $show_name);
    $file['show_id'] = $media_obj['id'];
    if (!$media_obj) {
        $data = $tvdb->getSeries($show_name, 'de');
        if (empty($data)) {