First push of semi working tmdb

This commit is contained in:
DariusIII
2015-11-02 13:33:19 +01:00
parent 294ad95a7a
commit fe5574c0b3
16 changed files with 90 additions and 1253 deletions
-1197
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -22,7 +22,7 @@ class Collection {
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+1 -1
View File
@@ -22,7 +22,7 @@ class Episode{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+1 -1
View File
@@ -24,7 +24,7 @@ class Movie{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
private $_tmdb;
/**
+1 -1
View File
@@ -25,7 +25,7 @@ class Person{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+1 -1
View File
@@ -22,7 +22,7 @@ class Role{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+1 -1
View File
@@ -18,7 +18,7 @@ class MovieRole extends Role{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+1 -1
View File
@@ -19,7 +19,7 @@ class TVShowRole extends Role{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+2 -2
View File
@@ -23,7 +23,7 @@ class Season{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
private $_idTVShow;
/**
@@ -147,7 +147,7 @@ class Season{
* Reload the content of this class.<br>
* Could be used to update or complete the information.
*
* @param \libs\Tmdb\TMDB $tmdb An instance of the API handler, necesary to make the API call.
* @param \newznab\libraries\Tmdb $tmdb An instance of the API handler, necesary to make the API call.
*/
public function reload($tmdb) {
$tmdb->getSeason($this->getTVShowID(), $this->getSeasonNumber());
+1 -1
View File
@@ -22,7 +22,7 @@ class TVShow{
// Class Variables
//------------------------------------------------------------------------------
private $_data;
public $_data;
/**
* Construct Class
+48
View File
@@ -0,0 +1,48 @@
<?php
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use newznab\processing\tv\TMDB;
$c = new newznab\ColorCLI();
$tmdb = new TMDB();
if (!empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
// Test if your TMDB API configuration is working
// If it works you should get a var dumped array of the show/season/episode entered
$season = (int)$argv[2];
$episode = (int)$argv[3];
// Search for a show
$series = $tmdb->client->searchTVShow((string)$argv[1]);
// Use the first show found (highest match) and get the requested season/episode from $argv
if ($series) {
print_r($series[0]);
if ($season > 0 AND $episode > 0) {
$episodeObj = $tmdb->client->getEpisode($series[0]->_data['id'], $season, $episode);
if ($episodeObj) {
print_r($episodeObj);
}
} else if ($season == 0 && $episode == 0) {
$episodeObj = $tmdb->client->getTVShow($series[0]->_data['id']);
if (is_array($episodeObj)) {
foreach ($episodeObj AS $ep) {
print_r($ep);
}
}
} else {
exit($c->error("Invalid episode data returned from TVMaze API."));
}
} else {
exit($c->error("Invalid show data returned from TVMaze API."));
}
} else {
exit($c->error("Invalid arguments. This script requires a text string (show name) followed by a season and episode number."));
}
-11
View File
@@ -422,17 +422,6 @@ class TmdbAPI {
return new Season($this->_call('tv/'. $idTVShow .'/season/' . $numSeason, $appendToResponse));
}*/
/**
* Get a Episode
*
* @param int $idEpisode The Episode id
* @param string $appendToResponse The extra append of the request, by default all
* @return Episode
*/
/*public function getEpisode($idEpisode, $appendToResponse = 'append_to_response=trailers,images,casts,translations'){
return new Episode($this->_call('tv/season/episode/' . $idEpisode, $appendToResponse));
}*/
/**
* Get a Episode
*
+2
View File
@@ -11,6 +11,7 @@ use newznab\Movie;
use newznab\Music;
use newznab\NameFixer;
use newznab\Nfo;
use newznab\processing\tv\TMDB;
use newznab\Sharing;
//use newznab\processing\tv\TvRage;
use newznab\processing\tv\TVDB;
@@ -261,6 +262,7 @@ class PostProcess
if ($processTV > 0) {
(new TVDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTVDB($groupID, $guidChar, $processTV);
(new TVMaze(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTVMaze($groupID, $guidChar, $processTV);
(new TMDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTMDB($groupID, $guidChar, $processTV);
//(new TvRage(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvRage($groupID, $guidChar, $processTV);
}
}
+23 -28
View File
@@ -69,7 +69,7 @@ class TMDB extends TV
if (is_array($release) && $release['name'] != '') {
// Find the Video ID if it already exists by checking the title.
$videoId = $this->getByTitle($release['cleanname']);
$videoId = $this->getByTitle($release['cleanname'], parent::TYPE_TV);
if ($videoId !== false) {
$tmdbid = $this->getSiteByID('tmdb', $videoId);
@@ -150,7 +150,7 @@ class TMDB extends TV
}
}
} //Processing failed, set the episode ID to the next processing group
$this->setVideoNotFound(parent::PROCESS_TVRAGE, $row['id']);
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
}
}
}
@@ -168,7 +168,7 @@ class TMDB extends TV
try {
//Try for the best match with AKAs embedded
$response = $this->client->singleSearch($cleanName);
$response = $this->client->searchTVShow($cleanName);
} catch (\Exception $error) {
}
@@ -180,7 +180,7 @@ class TMDB extends TV
if ($return === false) {
try {
//Try for the best match via full search (no AKAs can be returned)
$response = $this->client->search($cleanName);
$response = $this->client->searchCollection($cleanName);
} catch (\Exception $error) {
}
if (is_array($response)) {
@@ -280,19 +280,14 @@ class TMDB extends TV
{
$return = $response = false;
if ($airdate !== '') {
if ($videoId > 0) {
try {
$response = $this->client->getEpisodesByAirdate($tmdbid, $airdate);
} catch (\Exception $error) {
}
} else if ($videoId > 0) {
try {
$response = $this->client->getEpisodesByShowID($tmdbid);
$response = $this->client->getTVShow($tmdbid);
} catch (\Exception $error) {
}
} else {
try {
$response = $this->client->getEpisodeByNumber($tmdbid, $season, $episode);
$response = $this->client->getEpisode($tmdbid, $season, $episode);
} catch (\Exception $error) {
}
}
@@ -332,22 +327,22 @@ class TMDB extends TV
*/
private function formatShowArr($show)
{
$this->posterUrl = (string)(isset($show->mediumImage) ? $show->mediumImage : '');
$this->posterUrl = (string)(isset($show->_data['poster_path']) ? $show->_data['poster_path'] : '');
return [
'tmdbid' => (int)$show->id,
'tmdbid' => (int)$show->_data['id'],
'column' => 'tmdb',
'siteid' => (int)$show->id,
'title' => (string)$show->name,
'summary' => (string)$show->summary,
'started' => (string)$show->premiered,
'publisher' => (string)$show->network,
'country' => (string)$show->country,
'siteid' => (int)$show->_data['id'],
'title' => (string)$show->_data['name'],
'summary' => (string)$show->_data['overview'],
'started' => (string)$show->_data['first_air_date'],
'publisher' => (string)$show->_data['networks']->name,
'country' => (string)$show->_data['origin_country'],
'source' => (int)parent::SOURCE_TMDB,
'imdbid' => 0,
'tvdbid' => (int)(isset($show->externalIDs['thetvdb']) ? $show->externalIDs['thetvdb'] : 0),
'tvdbid' => 0,
'traktid' => 0,
'tvrageid' => (int)(isset($show->externalIDs['tvrage']) ? $show->externalIDs['tvrage'] : 0),
'tvrageid' => 0,
'tvmazeid' => 0
];
}
@@ -363,12 +358,12 @@ class TMDB extends TV
private function formatEpisodeArr($episode)
{
return [
'title' => (string)$episode->name,
'series' => (int)$episode->season,
'episode' => (int)$episode->number,
'se_complete' => (string)'S' . sprintf('%02d', $episode->season) . 'E' . sprintf('%02d', $episode->number),
'firstaired' => (string)$episode->airdate,
'summary' => (string)$episode->summary
'title' => (string)$episode->_data['name'],
'series' => (int)$episode->_data['season_number'],
'episode' => (int)$episode->_data['episode_number'],
'se_complete' => (string)'S' . sprintf('%02d', $episode->_data['season_number']) . 'E' . sprintf('%02d', $episode->_data['episode_number']),
'firstaired' => (string)$episode->_data['air_date'],
'summary' => (string)$episode->_data['overview']
];
}
}
+6 -6
View File
@@ -13,9 +13,9 @@ abstract class TV extends Videos
const SOURCE_NONE = 0; // No Scrape source
const SOURCE_TVDB = 1; // Scrape source was TVDB
const SOURCE_TVMAZE = 2; // Scrape source was TVMAZE
const SOURCE_TRAKT = 3; // Scrape source was TraktTV
const SOURCE_IMDB = 4; // Scrape source was IMDB
const SOURCE_TMDB = 5; // Scrape source was TMDB
const SOURCE_TMDB = 3; // Scrape source was TraktTV
const SOURCE_TRAKT = 4; // Scrape source was IMDB
const SOURCE_IMDB = 5; // Scrape source was TMDB
const SOURCE_TVRAGE = 6; // Scrape source was TvRage
// Anime Sources
@@ -24,9 +24,9 @@ abstract class TV extends Videos
// Processing signifiers
const PROCESS_TVDB = 0; // Process TVDB First
const PROCESS_TVMAZE = -1; // Process TVMaze Second
const PROCESS_TRAKT = -2; // Process Trakt Third
const PROCESS_IMDB = -3; // Process IMDB Fourth
const PROCESS_TMDB = -4; // Process TMDB Fifth
const PROCESS_TMDB = -2; // Process Trakt Third
const PROCESS_TRAKT = -3; // Process IMDB Fourth
const PROCESS_IMDB = -4; // Process TMDB Fifth
const PROCESS_TVRAGE = -5; // Process TvRage Sixth
const NO_MATCH_FOUND = -6; // Failed All Methods
+1 -1
View File
@@ -177,7 +177,7 @@ class TVMaze extends TV
}
}
} //Processing failed, set the episode ID to the next processing group
$this->setVideoNotFound(parent::PROCESS_TRAKT, $row['id']);
$this->setVideoNotFound(parent::PROCESS_TMDB, $row['id']);
}
}
}