Update MovieInfo model and related migration

This commit is contained in:
DariusIII
2017-09-28 14:42:00 +02:00
parent 879f28664d
commit bdab2cbd89
4 changed files with 324 additions and 265 deletions
+1
View File
@@ -1,4 +1,5 @@
2017-09-28 DariusIII
* Chg: Update MovieInfo model and related migration
* Chg: Update code style of Releases and ReleaseSearch
* Chg: Update paragonie/random_compat
* Chg: Update groupfixrelnames with new renaming method
+17 -1
View File
@@ -6,5 +6,21 @@ use Illuminate\Database\Eloquent\Model;
class MovieInfo extends Model
{
//
const CREATED_AT = 'createddate';
const UPDATED_AT = 'updateddate';
/**
* @var string
*/
protected $table = 'movieinfo';
/**
* @var bool
*/
protected $dateFormat = false;
/**
* @var array
*/
protected $guarded = ['id'];
}
@@ -15,7 +15,26 @@ class CreateMovieinfoTable extends Migration
{
Schema::create('movieinfo', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedMediumInteger('imdb');
$table->unsignedInteger('tmdbid')->default(0);
$table->string('title', 255)->default('');
$table->string('tagline', 1024)->default('');
$table->string('rating', 4)->default('');
$table->string('plot', 1024)->default('');
$table->string('year', 4)->default('');
$table->string('genre', 64)->default('');
$table->string('type', 32)->default('');
$table->string('director', 64)->default('');
$table->string('actors', 2000)->default('');
$table->string('language', 64)->default('');
$table->string('trailer', 255)->default('');
$table->tinyInteger('cover')->default(0);
$table->tinyInteger('backdrop')->default(0);
$table->dateTime('createddate');
$table->dateTime('updateddate');
$table->index('title', 'ix_movieinfo_title');
$table->unique('imdbid', 'ix_movieinfo_imdbid');
DB::statement('ALTER TABLE movieinfo CHANGE imdbid imdbid MEDIUMINT(7) UNSIGNED ZEROFILL NOT NULL');
});
}
+286 -263
View File
@@ -2,6 +2,7 @@
namespace nntmux;
use App\Models\MovieInfo;
use nntmux\db\DB;
use Tmdb\ApiToken;
use aharen\OMDbAPI;
@@ -173,24 +174,26 @@ class Movie
public function __construct(array $options = [])
{
$defaults = [
'Echo' => false,
'Logger' => null,
'ReleaseImage' => null,
'Settings' => null,
'TMDb' => null,
];
'Echo' => false,
'Logger' => null,
'ReleaseImage' => null,
'Settings' => null,
'TMDb' => null,
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo));
$this->client = new Client();
$this->tmdbtoken = new ApiToken(Settings::settingValue('APIs..tmdbkey'));
$this->tmdbclient = new TmdbClient($this->tmdbtoken, [
'cache' => [
'enabled' => false,
],
]
);
$this->tmdbclient = new TmdbClient(
$this->tmdbtoken,
[
'cache' => [
'enabled' => false,
],
]
);
$this->fanartapikey = Settings::settingValue('APIs..fanarttvkey');
$this->fanart = new FanartTV($this->fanartapikey);
$this->omdbapikey = Settings::settingValue('APIs..omdbkey');
@@ -219,15 +222,12 @@ class Movie
}
/**
* Get info for a IMDB id.
*
* @param int $imdbId
*
* @return array|bool
* @param $imdbId
* @return array|bool|\Illuminate\Database\Eloquent\Model|null|static
*/
public function getMovieInfo($imdbId)
{
return $this->pdo->queryOneRow(sprintf('SELECT * FROM movieinfo WHERE imdbid = %d', $imdbId));
return MovieInfo::query()->where('imdbid', $imdbId)->first();
}
/**
@@ -240,22 +240,25 @@ class Movie
public function getMovieInfoMultiImdb($imdbIDs): array
{
return $this->pdo->query(
sprintf('
sprintf(
'
SELECT DISTINCT movieinfo.*, releases.imdbid AS relimdb
FROM movieinfo
LEFT OUTER JOIN releases ON releases.imdbid = movieinfo.imdbid
WHERE movieinfo.imdbid IN (%s)',
str_replace(
',,',
',',
str_replace(
['(,', ' ,', ', )', ',)'],
'',
implode(',', $imdbIDs)
)
)
), true, NN_CACHE_EXPIRY_MEDIUM
);
str_replace(
',,',
',',
str_replace(
['(,', ' ,', ', )', ',)'],
'',
implode(',', $imdbIDs)
)
)
),
true,
NN_CACHE_EXPIRY_MEDIUM
);
}
/**
@@ -280,7 +283,8 @@ class Movie
$order = $this->getMovieOrder($orderBy);
$movies = $this->pdo->queryCalc(
sprintf("
sprintf(
"
SELECT SQL_CALC_FOUND_ROWS
m.imdbid,
GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id
@@ -293,19 +297,22 @@ class Movie
%s %s %s %s
GROUP BY m.imdbid
ORDER BY %s %s %s",
$this->showPasswords,
$this->getBrowseBy(),
(! empty($catsrch) ? $catsrch : ''),
($maxAge > 0
? 'AND r.postdate > NOW() - INTERVAL '.$maxAge.'DAY '
: ''
),
(count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
$order[0],
$order[1],
($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start)
), true, NN_CACHE_EXPIRY_MEDIUM
);
$this->showPasswords,
$this->getBrowseBy(),
(! empty($catsrch) ? $catsrch : ''),
(
$maxAge > 0
? 'AND r.postdate > NOW() - INTERVAL '.$maxAge.'DAY '
: ''
),
(count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
$order[0],
$order[1],
($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start)
),
true,
NN_CACHE_EXPIRY_MEDIUM
);
$movieIDs = $releaseIDs = false;
@@ -316,7 +323,8 @@ class Movie
}
}
$sql = sprintf("
$sql = sprintf(
"
SELECT
GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id,
GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') AS grp_rarinnerfilecount,
@@ -347,12 +355,12 @@ class Movie
AND r.id IN (%s) %s
GROUP BY m.imdbid
ORDER BY %s %s",
(is_array($movieIDs) ? implode(',', $movieIDs) : -1),
(is_array($releaseIDs) ? implode(',', $releaseIDs) : -1),
(! empty($catsrch) ? $catsrch : ''),
$order[0],
$order[1]
);
(is_array($movieIDs) ? implode(',', $movieIDs) : -1),
(is_array($releaseIDs) ? implode(',', $releaseIDs) : -1),
(! empty($catsrch) ? $catsrch : ''),
$order[0],
$order[1]
);
$return = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM);
if (! empty($return)) {
$return[0]['_totalcount'] = $movies['total'] ?? 0;
@@ -372,20 +380,20 @@ class Movie
{
$orderArr = explode('_', (($orderBy === '') ? 'MAX(r.postdate)' : $orderBy));
switch ($orderArr[0]) {
case 'title':
$orderField = 'm.title';
break;
case 'year':
$orderField = 'm.year';
break;
case 'rating':
$orderField = 'm.rating';
break;
case 'posted':
default:
$orderField = 'MAX(r.postdate)';
break;
}
case 'title':
$orderField = 'm.title';
break;
case 'year':
$orderField = 'm.year';
break;
case 'rating':
$orderField = 'm.rating';
break;
case 'posted':
default:
$orderField = 'MAX(r.postdate)';
break;
}
return [$orderField, isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1]) ? $orderArr[1] : 'desc'];
}
@@ -440,6 +448,7 @@ class Movie
* @param int $imdbID
*
* @return bool|string
* @throws \Exception
*/
public function getTrailer($imdbID)
{
@@ -447,8 +456,8 @@ class Movie
return false;
}
$trailer = $this->pdo->queryOneRow("SELECT trailer FROM movieinfo WHERE imdbid = $imdbID AND trailer != ''");
if ($trailer) {
$trailer = MovieInfo::query()->where('imdbid', $imdbID)->where('trailer', '!=', '')->first('trailer');
if ($trailer !== null) {
return $trailer['trailer'];
}
@@ -466,9 +475,7 @@ class Movie
$trailer = Utility::imdb_trailers($imdbID);
if ($trailer) {
$this->pdo->queryExec(
'UPDATE movieinfo SET trailer = '.$this->pdo->escapeString($trailer).' WHERE imdbid = '.$imdbID
);
MovieInfo::query()->where('imdbid', $imdbID)->update(['trailer' => $trailer]);
return $trailer;
}
@@ -491,8 +498,10 @@ class Movie
if (! empty($data['trailer'])) {
$data['trailer'] = str_ireplace(
'http://', 'https://', str_ireplace('watch?v=', 'embed/', $data['trailer'])
);
'http://',
'https://',
str_ireplace('watch?v=', 'embed/', $data['trailer'])
);
return $data['trailer'];
}
@@ -507,18 +516,18 @@ class Movie
}
}
$this->update([
'genres' => $this->checkTraktValue($data['genres']),
'imdbid' => $this->checkTraktValue($imdbid),
'language' => $this->checkTraktValue($data['language']),
'plot' => $this->checkTraktValue($data['overview']),
'rating' => round($this->checkTraktValue($data['rating']), 1),
'tagline' => $this->checkTraktValue($data['tagline']),
'title' => $this->checkTraktValue($data['title']),
'tmdbid' => $this->checkTraktValue($data['ids']['tmdb']),
'trailer' => $this->checkTraktValue($data['trailer']),
'cover' => $cover,
'year' => $this->checkTraktValue($data['year']),
]);
'genres' => $this->checkTraktValue($data['genres']),
'imdbid' => $this->checkTraktValue($imdbid),
'language' => $this->checkTraktValue($data['language']),
'plot' => $this->checkTraktValue($data['overview']),
'rating' => round($this->checkTraktValue($data['rating']), 1),
'tagline' => $this->checkTraktValue($data['tagline']),
'title' => $this->checkTraktValue($data['title']),
'tmdbid' => $this->checkTraktValue($data['ids']['tmdb']),
'trailer' => $this->checkTraktValue($data['trailer']),
'cover' => $cover,
'year' => $this->checkTraktValue($data['year']),
]);
}
/**
@@ -582,9 +591,9 @@ class Movie
public function getColumnKeys(): array
{
return [
'actors', 'backdrop', 'cover', 'director', 'genre', 'imdbid', 'language',
'plot', 'rating', 'tagline', 'title', 'tmdbid', 'trailer', 'type', 'year',
];
'actors', 'backdrop', 'cover', 'director', 'genre', 'imdbid', 'language',
'plot', 'rating', 'tagline', 'title', 'tmdbid', 'trailer', 'type', 'year',
];
}
/**
@@ -603,10 +612,10 @@ class Movie
$validKeys = $this->getColumnKeys();
$query = [
'0' => 'INSERT INTO movieinfo (updateddate, createddate, ',
'1' => ' VALUES (NOW(), NOW(), ',
'2' => 'ON DUPLICATE KEY UPDATE updateddate = NOW(), ',
];
'0' => 'INSERT INTO movieinfo (updateddate, createddate, ',
'1' => ' VALUES (NOW(), NOW(), ',
'2' => 'ON DUPLICATE KEY UPDATE updateddate = NOW(), ',
];
$found = 0;
foreach ($values as $key => $value) {
if (! empty($value) && in_array($key, $validKeys, false)) {
@@ -772,32 +781,33 @@ class Movie
$mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
$movieID = $this->update([
'actors' => html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8'),
'backdrop' => $mov['backdrop'],
'cover' => $mov['cover'],
'director' => html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8'),
'genre' => html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8'),
'imdbid' => $mov['imdbid'],
'language' => html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8'),
'plot' => html_entity_decode(preg_replace('/\s+See full summary »/', ' ', $mov['plot']), ENT_QUOTES, 'UTF-8'),
'rating' => round($mov['rating'], 1),
'tagline' => html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8'),
'title' => $mov['title'],
'tmdbid' => $mov['tmdbid'],
'type' => html_entity_decode(ucwords(preg_replace('/[\.\_]/', ' ', $mov['type'])), ENT_QUOTES, 'UTF-8'),
'year' => $mov['year'],
]);
'actors' => html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8'),
'backdrop' => $mov['backdrop'],
'cover' => $mov['cover'],
'director' => html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8'),
'genre' => html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8'),
'imdbid' => $mov['imdbid'],
'language' => html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8'),
'plot' => html_entity_decode(preg_replace('/\s+See full summary »/', ' ', $mov['plot']), ENT_QUOTES, 'UTF-8'),
'rating' => round($mov['rating'], 1),
'tagline' => html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8'),
'title' => $mov['title'],
'tmdbid' => $mov['tmdbid'],
'type' => html_entity_decode(ucwords(preg_replace('/[\.\_]/', ' ', $mov['type'])), ENT_QUOTES, 'UTF-8'),
'year' => $mov['year'],
]);
if ($this->echooutput && $this->service !== '') {
ColorCLI::doEcho(
ColorCLI::headerOver(($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ')).
ColorCLI::primary($mov['title'].
' ('.
$mov['year'].
') - '.
$mov['imdbid']
)
);
ColorCLI::headerOver(($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ')).
ColorCLI::primary(
$mov['title'].
' ('.
$mov['year'].
') - '.
$mov['imdbid']
)
);
}
return $movieID !== 0;
@@ -876,16 +886,16 @@ class Movie
if ($percent < 40) {
if ($this->debug) {
$this->debugging->log(
__CLASS__,
__FUNCTION__,
'Found ('.
$ret['title'].
') from TMDB, but it\'s only '.
$percent.
'% similar to ('.
$this->currentTitle.')',
Logger::LOG_INFO
);
__CLASS__,
__FUNCTION__,
'Found ('.
$ret['title'].
') from TMDB, but it\'s only '.
$percent.
'% similar to ('.
$this->currentTitle.')',
Logger::LOG_INFO
);
}
return false;
@@ -943,31 +953,31 @@ class Movie
protected function fetchIMDBProperties($imdbId)
{
$imdb_regex = [
'title' => '/<title>(.*?)\s?\(.*?<\/title>/i',
'tagline' => '/taglines:<\/h4>\s([^<]+)/i',
'plot' => '/<p itemprop="description">\s*?(.*?)\s*?<\/p>/i',
'rating' => '/"ratingValue">([\d.]+)<\/span>/i',
'year' => '/<title>.*?\(.*?(\d{4}).*?<\/title>/i',
'cover' => '/<link rel=\'image_src\' href="(http:\/\/ia\.media-imdb\.com.+\.jpg)">/',
];
'title' => '/<title>(.*?)\s?\(.*?<\/title>/i',
'tagline' => '/taglines:<\/h4>\s([^<]+)/i',
'plot' => '/<p itemprop="description">\s*?(.*?)\s*?<\/p>/i',
'rating' => '/"ratingValue">([\d.]+)<\/span>/i',
'year' => '/<title>.*?\(.*?(\d{4}).*?<\/title>/i',
'cover' => '/<link rel=\'image_src\' href="(http:\/\/ia\.media-imdb\.com.+\.jpg)">/',
];
$imdb_regex_multi = [
'genre' => '/href="\/genre\/(.*?)\?/i',
'language' => '/<a href="\/language\/.+?\'url\'>(.+?)<\/a>/s',
'type' => '/<meta property=\'og\:type\' content=\"(.+)\" \/>/i',
];
'genre' => '/href="\/genre\/(.*?)\?/i',
'language' => '/<a href="\/language\/.+?\'url\'>(.+?)<\/a>/s',
'type' => '/<meta property=\'og\:type\' content=\"(.+)\" \/>/i',
];
try {
$buffer =
$this->client->get(
'http://'.($this->imdburl === false ? 'www' : 'akas').'.imdb.com/title/tt'.$imdbId.'/',
['headers' => [
'Accept-Language' => (Settings::settingValue('indexer.categorise.imdblanguage') !== '') ? Settings::settingValue('indexer.categorise.imdblanguage') : 'en',
'useragent' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) '.
'Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10', 'foo=bar',
],
]
)->getBody()->getContents();
$this->client->get(
'http://'.($this->imdburl === false ? 'www' : 'akas').'.imdb.com/title/tt'.$imdbId.'/',
['headers' => [
'Accept-Language' => (Settings::settingValue('indexer.categorise.imdblanguage') !== '') ? Settings::settingValue('indexer.categorise.imdblanguage') : 'en',
'useragent' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) '.
'Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10', 'foo=bar',
],
]
)->getBody()->getContents();
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getCode() === 404) {
@@ -1007,16 +1017,16 @@ class Movie
if ($percent < 40) {
if ($this->debug) {
$this->debugging->log(
__CLASS__,
__FUNCTION__,
'Found ('.
$ret['title'].
') from IMDB, but it\'s only '.
$percent.
'% similar to ('.
$this->currentTitle.')',
Logger::LOG_INFO
);
__CLASS__,
__FUNCTION__,
'Found ('.
$ret['title'].
') from IMDB, but it\'s only '.
$percent.
'% similar to ('.
$this->currentTitle.')',
Logger::LOG_INFO
);
}
return false;
@@ -1095,17 +1105,17 @@ class Movie
if (is_object($resp) && $resp->message === 'OK' && $resp->data->Response !== 'False') {
$ret = [
'title' => ! empty($resp->data->Title) ? $resp->data->Title : '',
'cover' => ! empty($resp->data->Poster) ? $resp->data->Poster : '',
'genre' => ! empty($resp->data->Genre) ? $resp->data->Genre : '',
'year' => ! empty($resp->data->Year) ? $resp->data->Year : '',
'plot' => ! empty($resp->data->Plot) ? $resp->data->Plot : '',
'rating' => ! empty($resp->data->imdbRating) ? $resp->data->imdbRating : '',
'tagline' => ! empty($resp->data->Tagline) ? $resp->data->Tagline : '',
'director' => ! empty($resp->data->Director) ? $resp->data->Director : '',
'actors' => ! empty($resp->data->Actors) ? $resp->data->Actors : '',
'language' => ! empty($resp->data->Language) ? $resp->data->Language : '',
];
'title' => ! empty($resp->data->Title) ? $resp->data->Title : '',
'cover' => ! empty($resp->data->Poster) ? $resp->data->Poster : '',
'genre' => ! empty($resp->data->Genre) ? $resp->data->Genre : '',
'year' => ! empty($resp->data->Year) ? $resp->data->Year : '',
'plot' => ! empty($resp->data->Plot) ? $resp->data->Plot : '',
'rating' => ! empty($resp->data->imdbRating) ? $resp->data->imdbRating : '',
'tagline' => ! empty($resp->data->Tagline) ? $resp->data->Tagline : '',
'director' => ! empty($resp->data->Director) ? $resp->data->Director : '',
'actors' => ! empty($resp->data->Actors) ? $resp->data->Actors : '',
'language' => ! empty($resp->data->Language) ? $resp->data->Language : '',
];
if ($this->echooutput) {
ColorCLI::doEcho(ColorCLI::alternateOver('OMDbAPI Found ').ColorCLI::headerOver($ret['title']), true);
@@ -1174,7 +1184,8 @@ class Movie
// Get all releases without an IMDB id.
$res = $this->pdo->query(
sprintf('
sprintf(
'
SELECT searchname, id
FROM releases
%s
@@ -1182,13 +1193,13 @@ class Movie
AND nzbstatus = 1
%s %s %s
LIMIT %d',
$this->catWhere,
($groupID === '' ? '' : ('AND groups_id = '.$groupID)),
($guidChar === '' ? '' : 'AND leftguid = '.$this->pdo->escapeString($guidChar)),
($lookupIMDB === 2 ? 'AND isrenamed = 1' : ''),
$this->movieqty
)
);
$this->catWhere,
($groupID === '' ? '' : ('AND groups_id = '.$groupID)),
($guidChar === '' ? '' : 'AND leftguid = '.$this->pdo->escapeString($guidChar)),
($lookupIMDB === 2 ? 'AND isrenamed = 1' : ''),
$this->movieqty
)
);
$movieCount = count($res);
if ($movieCount > 0) {
@@ -1303,7 +1314,8 @@ class Movie
$andYearIn .= $end.')';
}
$IMDBCheck = $this->pdo->queryOneRow(
sprintf('%s WHERE title %s %s', $query, $this->pdo->likeString($this->currentTitle), $andYearIn));
sprintf('%s WHERE title %s %s', $query, $this->pdo->likeString($this->currentTitle), $andYearIn)
);
// Look by %word%word%word% etc..
if ($IMDBCheck === false) {
@@ -1313,10 +1325,13 @@ class Movie
$tempTitle .= str_replace(["'", '!', '"'], '', $piece).'%';
}
$IMDBCheck = $this->pdo->queryOneRow(
sprintf("%s WHERE replace(replace(title, \"'\", ''), '!', '') %s %s",
$query, $this->pdo->likeString($tempTitle), $andYearIn
)
);
sprintf(
"%s WHERE replace(replace(title, \"'\", ''), '!', '') %s %s",
$query,
$this->pdo->likeString($tempTitle),
$andYearIn
)
);
}
// Try replacing er with re ?
@@ -1324,10 +1339,13 @@ class Movie
$tempTitle = str_replace('er', 're', $this->currentTitle);
if ($tempTitle !== $this->currentTitle) {
$IMDBCheck = $this->pdo->queryOneRow(
sprintf('%s WHERE title %s %s',
$query, $this->pdo->likeString($tempTitle), $andYearIn
)
);
sprintf(
'%s WHERE title %s %s',
$query,
$this->pdo->likeString($tempTitle),
$andYearIn
)
);
// Final check if everything else failed.
if ($IMDBCheck === false) {
@@ -1337,21 +1355,25 @@ class Movie
$tempTitle .= str_replace(["'", '!', '"'], '', $piece).'%';
}
$IMDBCheck = $this->pdo->queryOneRow(
sprintf("%s WHERE replace(replace(replace(title, \"'\", ''), '!', ''), '\"', '') %s %s",
$query, $this->pdo->likeString($tempTitle), $andYearIn
)
);
sprintf(
"%s WHERE replace(replace(replace(title, \"'\", ''), '!', ''), '\"', '') %s %s",
$query,
$this->pdo->likeString($tempTitle),
$andYearIn
)
);
}
}
}
return
$IMDBCheck === false
? false
: (is_numeric($IMDBCheck['imdbid'])
? (int) $IMDBCheck['imdbid']
: false
);
$IMDBCheck === false
? false
: (
is_numeric($IMDBCheck['imdbid'])
? (int) $IMDBCheck['imdbid']
: false
);
}
/**
@@ -1383,16 +1405,16 @@ class Movie
{
try {
$buffer = $this->client->get(
'https://www.google.com/search?hl=en&as_q=&as_epq='.
urlencode(
$this->currentTitle.
' '.
$this->currentYear
).
'&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch='.
urlencode('www.imdb.com/title/').
'&as_occt=title&safe=images&tbs=&as_filetype=&as_rights='
)->getBody()->getContents();
'https://www.google.com/search?hl=en&as_q=&as_epq='.
urlencode(
$this->currentTitle.
' '.
$this->currentYear
).
'&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch='.
urlencode('www.imdb.com/title/').
'&as_occt=title&safe=images&tbs=&as_filetype=&as_rights='
)->getBody()->getContents();
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getCode() === 404) {
@@ -1432,16 +1454,16 @@ class Movie
{
try {
$buffer = $this->client->get(
'http://www.bing.com/search?q='.
urlencode(
'("'.
$this->currentTitle.
'" and "'.
$this->currentYear.
'") site:www.imdb.com/title/'
).
'&qs=n&form=QBLH&filt=all'
)->getBody()->getContents();
'http://www.bing.com/search?q='.
urlencode(
'("'.
$this->currentTitle.
'" and "'.
$this->currentYear.
'") site:www.imdb.com/title/'
).
'&qs=n&form=QBLH&filt=all'
)->getBody()->getContents();
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getCode() === 404) {
@@ -1476,29 +1498,30 @@ class Movie
{
try {
$buffer = $this->client->get(
'http://search.yahoo.com/search?n=10&ei=UTF-8&va_vt=title&vo_vt=any&ve_vt=any&vp_vt=any&vf=all&vm=p&fl=0&fr=fp-top&p='.
urlencode(
''.
implode('+',
explode(
' ',
preg_replace(
'/\s+/',
' ',
preg_replace(
'/\W/',
' ',
$this->currentTitle
)
)
)
).
'+'.
$this->currentYear
).
'&vs='.
urlencode('www.imdb.com/title/')
)->getBody()->getContents();
'http://search.yahoo.com/search?n=10&ei=UTF-8&va_vt=title&vo_vt=any&ve_vt=any&vp_vt=any&vf=all&vm=p&fl=0&fr=fp-top&p='.
urlencode(
''.
implode(
'+',
explode(
' ',
preg_replace(
'/\s+/',
' ',
preg_replace(
'/\W/',
' ',
$this->currentTitle
)
)
)
).
'+'.
$this->currentYear
).
'&vs='.
urlencode('www.imdb.com/title/')
)->getBody()->getContents();
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getCode() === 404) {
@@ -1555,7 +1578,7 @@ class Movie
// Check if we got something.
if ($name !== '') {
// If we still have any of the words in $followingList, remove them.
// If we still have any of the words in $followingList, remove them.
$name = preg_replace('/'.$followingList.'/i', ' ', $name);
// Remove periods, underscored, anything between parenthesis.
$name = preg_replace('/\(.*?\)|[._]/i', ' ', $name);
@@ -1584,32 +1607,32 @@ class Movie
public function getGenres(): array
{
return [
'Action',
'Adventure',
'Animation',
'Biography',
'Comedy',
'Crime',
'Documentary',
'Drama',
'Family',
'Fantasy',
'Film-Noir',
'Game-Show',
'History',
'Horror',
'Music',
'Musical',
'Mystery',
'News',
'Reality-TV',
'Romance',
'Sci-Fi',
'Sport',
'Talk-Show',
'Thriller',
'War',
'Western',
];
'Action',
'Adventure',
'Animation',
'Biography',
'Comedy',
'Crime',
'Documentary',
'Drama',
'Family',
'Fantasy',
'Film-Noir',
'Game-Show',
'History',
'Horror',
'Music',
'Musical',
'Mystery',
'News',
'Reality-TV',
'Romance',
'Sci-Fi',
'Sport',
'Talk-Show',
'Thriller',
'War',
'Western',
];
}
}