mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add OMDbAPI apikey support for future use as it will go private soon
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2017-05-15 DariusIII
|
||||
* Chg: Add OMDbAPI apikey support for future use as it will go private soon
|
||||
* Chg: Update aharen/omdbapi to version 2.0.6
|
||||
2017-05-12 DariusIII
|
||||
* Chg: Declare proper @var for pdo (DB) in DnzbFailures
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
</last>
|
||||
</scripts>
|
||||
<sql>
|
||||
<db>307</db>
|
||||
<file>307</file>
|
||||
<db>308</db>
|
||||
<file>308</file>
|
||||
</sql>
|
||||
</versions>
|
||||
</nntmux>
|
||||
|
||||
+70
-21
@@ -115,6 +115,11 @@ class Movie
|
||||
*/
|
||||
public $fanartapikey;
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
*/
|
||||
public $omdbapikey;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -170,9 +175,12 @@ class Movie
|
||||
]
|
||||
]
|
||||
);
|
||||
$this->omdb = new OMDbAPI();
|
||||
$this->fanartapikey = Settings::value('APIs..fanarttvkey');
|
||||
$this->fanart = new FanartTV($this->fanartapikey);
|
||||
$this->omdbapikey = Settings::value('APIs..omdbkey');
|
||||
if ($this->omdbapikey !== '') {
|
||||
$this->omdb = new OMDbAPI($this->omdbapikey);
|
||||
}
|
||||
|
||||
$this->lookuplanguage = Settings::value('indexer.categorise.imdblanguage') !== '' ? (string)Settings::value('indexer.categorise.imdblanguage') : 'en';
|
||||
|
||||
@@ -632,14 +640,11 @@ class Movie
|
||||
*
|
||||
* @param $variable
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkVariable(&$variable): string
|
||||
protected function checkVariable(&$variable): bool
|
||||
{
|
||||
if (isset($variable) && $variable !== '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return isset($variable) && $variable !== '' ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,7 +691,10 @@ class Movie
|
||||
|
||||
// Check TRAKT for movie info
|
||||
$trakt = $this->fetchTraktTVProperties($imdbId);
|
||||
if (!$imdb && !$tmdb && !$trakt) {
|
||||
|
||||
// Check OMDb for movie info
|
||||
$omdb = $this->fetchOmdbAPIproperties($imdbId);
|
||||
if (!$imdb && !$tmdb && !$trakt && !$omdb) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -701,13 +709,15 @@ class Movie
|
||||
$mov['imdbid'] = $imdbId;
|
||||
$mov['tmdbid'] = (!isset($tmdb['tmdbid']) || $tmdb['tmdbid'] === '') ? 0 : $tmdb['tmdbid'];
|
||||
|
||||
// Prefer Fanart.tv cover over TMDB and TMDB over IMDB.
|
||||
// Prefer Fanart.tv cover over TMDB,TMDB over IMDB and IMDB over OMDB.
|
||||
if ($this->checkVariable($fanart['cover'])) {
|
||||
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $fanart['cover'], $this->imgSavePath);
|
||||
} else if ($this->checkVariable($tmdb['cover'])) {
|
||||
} elseif ($this->checkVariable($tmdb['cover'])) {
|
||||
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $tmdb['cover'], $this->imgSavePath);
|
||||
} else if ($this->checkVariable($imdb['cover'])) {
|
||||
} elseif ($this->checkVariable($imdb['cover'])) {
|
||||
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $imdb['cover'], $this->imgSavePath);
|
||||
} elseif ($this->checkVariable($omdb['cover'])) {
|
||||
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $omdb['cover'], $this->imgSavePath);
|
||||
}
|
||||
|
||||
// Backdrops.
|
||||
@@ -863,7 +873,7 @@ class Movie
|
||||
if ($percent < 40) {
|
||||
if ($this->debug) {
|
||||
$this->debugging->log(
|
||||
get_class(),
|
||||
__CLASS__,
|
||||
__FUNCTION__,
|
||||
'Found (' .
|
||||
$ret['title'] .
|
||||
@@ -991,7 +1001,7 @@ class Movie
|
||||
if ($percent < 40) {
|
||||
if ($this->debug) {
|
||||
$this->debugging->log(
|
||||
get_class(),
|
||||
__CLASS__,
|
||||
__FUNCTION__,
|
||||
'Found (' .
|
||||
$ret['title'] .
|
||||
@@ -1059,6 +1069,43 @@ class Movie
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch OMDb backdrop / cover / title.
|
||||
*
|
||||
* @param $imdbId
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
protected function fetchOmdbAPIProperties($imdbId)
|
||||
{
|
||||
if ($this->omdbapikey !== '') {
|
||||
$this->omdb = new OMDbAPI($this->omdbapikey);
|
||||
}
|
||||
$resp = $this->omdb->search('tt' . $imdbId, 'movie');
|
||||
|
||||
if ($resp->data->Response !== 'False') {
|
||||
$ret = [];
|
||||
|
||||
if (isset($resp->data->Search[0]->Title)) {
|
||||
$ret['title'] = $resp->data->Search[0]->Title;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($resp->data->Search[0]->Poster)) {
|
||||
$ret['cover'] = $resp->data->Search[0]->Poster;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(ColorCLI::alternateOver('OMDbAPI Found ') . ColorCLI::headerOver($ret['title']), true);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a release with a IMDB id.
|
||||
*
|
||||
@@ -1165,16 +1212,18 @@ class Movie
|
||||
}
|
||||
}
|
||||
|
||||
// Check OMDB api.
|
||||
$buffer = $this->omdb->search($this->currentTitle, 'movies', $this->currentYear !== false ? "'" . $this->currentYear . "'" : '');
|
||||
if ($this->omdbapikey !== '') {
|
||||
// Check OMDB api.
|
||||
$buffer = $this->omdb->search($this->currentTitle, 'movies', $this->currentYear !== false ? "'" . $this->currentYear . "'" : '');
|
||||
|
||||
if (!empty($buffer) && $buffer->data->Response !== 'False') {
|
||||
$getIMDBid = $buffer->data->Search[0]->imdbID;
|
||||
if (!empty($buffer) && $buffer->data->Response !== 'False') {
|
||||
$getIMDBid = $buffer->data->Search[0]->imdbID;
|
||||
|
||||
if (!empty($getIMDBid)) {
|
||||
$imdbID = $this->doMovieUpdate($getIMDBid, 'OMDbAPI', $arr['id']);
|
||||
if ($imdbID !== false) {
|
||||
continue;
|
||||
if (!empty($getIMDBid)) {
|
||||
$imdbID = $this->doMovieUpdate($getIMDBid, 'OMDbAPI', $arr['id']);
|
||||
if ($imdbID !== false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Add OmdbAPI key setting to settings table
|
||||
|
||||
INSERT IGNORE INTO settings (section, subsection, name, value, hint, setting) VALUES ('APIs', '', 'omdbkey', '',
|
||||
'OmdbAPI key obtained from Omdb.Used for Omdb API lookups', 'omdbkey');
|
||||
@@ -109,6 +109,7 @@ APIs amazonpubkey AKIAIPDNG5EU7LB4AD3Q The amazon public api key. Used for musi
|
||||
APIs giantbombkey The giantbomb api key. Used for game lookups. giantbombkey
|
||||
APIs anidbkey The Anidb api key. Used for Anime lookups. anidbkey
|
||||
APIs fanarttvkey The Fanart.tv api key. Used for Fanart.tv lookups. Fanart.tv would appreciate it if you use this service to help them out by adding high quality images not already available on TMDB. fanarttvkey
|
||||
APIs omdbkey OmdbAPI key obtained from Omdb.Used for Omdb API lookups omdbkey
|
||||
APIs rottentomatokey qxbxyngtujprvw7jxam2m6na The api key used for access to rotten tomatoes. rottentomatokey
|
||||
APIs tmdbkey 9a4e16adddcd1e86da19bcaf5ff3c2a3 The API key used for access to TMDb. tmdbkey
|
||||
APIs trakttvclientkey The Trakt.tv API v2 Client ID (SHA256 hash - 64 characters long string). Used for movie and tv lookups. trakttvclientkey
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 214.
|
@@ -249,6 +249,17 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:180px;"><label for="omdbkey">Omdb API key:</label></td>
|
||||
<td>
|
||||
<input id="omdbkey" class="long" name="omdbkey" type="text" value="{$site->omdbkey}"/>
|
||||
|
||||
<div class="hint">OmdbAPI key obtained from Omdb.Used for OmdbAPI lookups. This key is private and needs
|
||||
monthly pledge. You can check the info on OmdbAPI site http://www.omdbapi.com/. You need an pledge
|
||||
with poster api access (currently 5$/month).
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="width:180px;"><label for="giantbombkey">Giant Bomb API Key:</label></td>
|
||||
|
||||
Reference in New Issue
Block a user