From 1267a103feebd91173b1f147ab4c05ee0c96c5d3 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 3 Dec 2018 14:21:56 +0100 Subject: [PATCH] Replace tmdb-php/api with tmdb-php/laravel package --- .env.example | 3 ++ Blacklight/Movie.php | 43 ++++++-------------------- Changelog | 1 + composer.json | 2 +- composer.lock | 72 +++++++++++++++++++++++++++++++++++++++++++- config/tmdb.php | 40 ++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 36 deletions(-) create mode 100644 config/tmdb.php diff --git a/.env.example b/.env.example index 9eedd5dc4..590cc59b5 100644 --- a/.env.example +++ b/.env.example @@ -112,3 +112,6 @@ SMARTY_CACHE_DRIVER=file FIREWALL_ENABLED=false IGDB_KEY= +TMDB_APIKEY= +TMDB_CACHE=false +TMDB_LOG=false diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 4e6d4a9e4..df4a375e8 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -4,7 +4,6 @@ namespace Blacklight; use Imdb\Title; use Imdb\Config; -use Tmdb\ApiToken; use aharen\OMDbAPI; use Imdb\TitleSearch; use GuzzleHttp\Client; @@ -12,9 +11,7 @@ use App\Models\Release; use App\Models\Category; use App\Models\Settings; use App\Models\MovieInfo; -use Tmdb\Helper\ImageHelper; use Illuminate\Support\Carbon; -use Tmdb\Client as TmdbClient; use Blacklight\utility\Utility; use DariusIII\ItunesApi\iTunes; use Blacklight\libraries\FanartTV; @@ -23,7 +20,8 @@ use Illuminate\Support\Facades\File; use Tmdb\Exception\TmdbApiException; use Blacklight\processing\tv\TraktTv; use Illuminate\Support\Facades\Cache; -use Tmdb\Repository\ConfigurationRepository; +use Tmdb\Helper\ImageHelper; +use Tmdb\Laravel\Facades\Tmdb; use DariusIII\ItunesApi\Exceptions\MovieNotFoundException; use DariusIII\ItunesApi\Exceptions\SearchNoResultsException; @@ -146,31 +144,16 @@ class Movie */ private $config; - /** - * @var \Tmdb\Repository\ConfigurationRepository - */ - protected $configRepository; - /** * @var \Tmdb\Helper\ImageHelper */ protected $helper; - /** - * @var \Tmdb\Model\Configuration - */ - protected $tmdbconfig; - /** * @var null|string */ protected $traktcheck; - /** - * @var null|string - */ - protected $tmdbtokencheck; - /** * @var \Blacklight\ColorCLI */ @@ -199,18 +182,6 @@ class Movie $this->traktTv = new TraktTv(['Settings' => null]); } $this->client = new Client(); - $this->tmdbtokencheck = Settings::settingValue('APIs..tmdbkey'); - if ($this->tmdbtokencheck !== null) { - $this->tmdbtoken = new ApiToken($this->tmdbtokencheck); - $this->tmdbclient = new TmdbClient($this->tmdbtoken, [ - 'cache' => [ - 'enabled' => false, - ], - ]); - $this->configRepository = new ConfigurationRepository($this->tmdbclient); - $this->tmdbconfig = $this->configRepository->load(); - $this->helper = new ImageHelper($this->tmdbconfig); - } $this->fanartapikey = Settings::settingValue('APIs..fanarttvkey'); if ($this->fanartapikey !== null) { $this->fanart = new FanartTV($this->fanartapikey); @@ -220,6 +191,8 @@ class Movie $this->omdbApi = new OMDbAPI($this->omdbapikey); } + $this->helper = ImageHelper::class; + $this->lookuplanguage = Settings::settingValue('indexer.categorise.imdblanguage') !== '' ? (string) Settings::settingValue('indexer.categorise.imdblanguage') : 'en'; $this->config = new Config(); $this->config->language = $this->lookuplanguage; @@ -474,7 +447,9 @@ class Movie if (! empty($data['trailer'])) { $data['trailer'] = str_ireplace( - ['watch?v=', 'http://'], ['embed/', 'https://'], $data['trailer'] + ['watch?v=', 'http://'], + ['embed/', 'https://'], + $data['trailer'] ); } $imdbid = (strpos($data['ids']['imdb'], 'tt') === 0) ? substr($data['ids']['imdb'], 2) : $data['ids']['imdb']; @@ -824,7 +799,7 @@ class Movie $lookupId = $text === false && \strlen($imdbId) === 7 ? 'tt'.$imdbId : $imdbId; try { - $tmdbLookup = $this->tmdbclient->getMoviesApi()->getMovie($lookupId, ['append_to_response' => 'credits']); + $tmdbLookup = Tmdb::getMoviesApi()->getMovie($lookupId, ['append_to_response' => 'credits']); } catch (TmdbApiException $error) { if (Utility::isCLI()) { $this->colorCli->error($error->getMessage()); @@ -1270,7 +1245,7 @@ class Movie // Check on The Movie Database. if ($movieUpdated === false) { - $data = $this->tmdbclient->getSearchApi()->searchMovies($this->currentTitle); + $data = Tmdb::getSearchApi()->searchMovies($this->currentTitle); if (($data['total_results'] > 0) && ! empty($data['results'])) { foreach ($data['results'] as $result) { if (! empty($result['id'])) { diff --git a/Changelog b/Changelog index 581d4bb98..cb903bd6d 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-12-03 DariusIII + * Chg: Replace tmdb-php/api with tmdb-php/laravel package * Chg: Update used libraries to their latest versions 2018-12-02 DariusIII * Chg: Update symfony/contracts to version 1.0.1 diff --git a/composer.json b/composer.json index ec2f9726c..f3902031c 100755 --- a/composer.json +++ b/composer.json @@ -120,7 +120,7 @@ "php-ffmpeg/php-ffmpeg": "^0.13.0", "php-http/guzzle6-adapter": "^1.1", "php-http/message": "^1.6", - "php-tmdb/api": "~2.1", + "php-tmdb/laravel": "^1.1", "pragmarx/firewall": "^2.2", "predis/predis": "^1.1", "propaganistas/laravel-disposable-email": "^2.0", diff --git a/composer.lock b/composer.lock index c80353ae5..4abf0d88b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a96aa076bf4831517b12c06f955015c7", + "content-hash": "05c780c9c597220db9498c7153b378e5", "packages": [ { "name": "aharen/omdbapi", @@ -4152,6 +4152,76 @@ ], "time": "2018-11-28T20:35:27+00:00" }, + { + "name": "php-tmdb/laravel", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-tmdb/laravel.git", + "reference": "0468624e8ff245c5766c8745e6ac43e3ccbf05b1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-tmdb/laravel/zipball/0468624e8ff245c5766c8745e6ac43e3ccbf05b1", + "reference": "0468624e8ff245c5766c8745e6ac43e3ccbf05b1", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.0 || ~4.0", + "php": ">=5.4.0", + "php-tmdb/api": "~2.0" + }, + "require-dev": { + "doctrine/cache": ">=1.3.0", + "illuminate/events": "~5.0", + "monolog/monolog": ">=1.7.0", + "phpunit/phpunit": "~4.5", + "symfony/event-dispatcher": "~2.8|~3.0" + }, + "suggest": { + "doctrine/cache": "Required if you want to make use of caching features.", + "monolog/monolog": "Required if you want to make use of logging features." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Tmdb\\Laravel\\TmdbServiceProvider" + ], + "aliases": { + "Tmdb": "Tmdb\\Laravel\\Facades\\Tmdb" + } + } + }, + "autoload": { + "psr-4": { + "Tmdb\\Laravel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Redeman", + "email": "markredeman@gmail.com" + } + ], + "description": "Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.", + "keywords": [ + "api", + "laravel", + "movie", + "php", + "tmdb", + "tv", + "tv show", + "tvdb", + "wrapper" + ], + "time": "2018-05-02T19:55:50+00:00" + }, { "name": "pragmarx/firewall", "version": "v2.2.1", diff --git a/config/tmdb.php b/config/tmdb.php new file mode 100644 index 000000000..f6edfc956 --- /dev/null +++ b/config/tmdb.php @@ -0,0 +1,40 @@ + + * @copyright (c) 2014, Mark Redeman + */ +return [ + /* + * Api key + */ + 'api_key' => env('TMDB_APIKEY', ''), + + /** + * Client options + */ + 'options' => [ + /** + * Use https + */ + 'secure' => true, + + /* + * Cache + */ + 'cache' => [ + 'enabled' => env('TMDB_CACHE', false), + // Keep the path empty or remove it entirely to default to storage/tmdb + 'path' => storage_path('tmdb') + ], + + /* + * Log + */ + 'log' => [ + 'enabled' => env('TMDB_LOG', false), + // Keep the path empty or remove it entirely to default to storage/logs/tmdb.log + 'path' => storage_path('logs/tmdb.log') + ] + ], +];