diff --git a/app/Commands/TraktDebug.php b/app/Commands/TraktDebug.php index 99aa120..f9a783e 100644 --- a/app/Commands/TraktDebug.php +++ b/app/Commands/TraktDebug.php @@ -6,14 +6,13 @@ namespace App\Commands; use App\Services\Trakt; use Illuminate\Support\Arr; -use Illuminate\Contracts\Config\Repository; class TraktDebug extends Command { protected $signature = 'trakt:debug {endpoint : Trakt API endpoint to call} {method=GET : HTTP method to use} {--d|data=* : data}'; protected $description = 'Make arbitrary requests to Trakt API.' . PHP_EOL . '-d should be formatted with key=value or key:=value for non-strings'; - public function handle(Trakt $trakt, Repository $config): int + public function handle(Trakt $trakt): int { $body = $this->getBody(); $method = $this->argument('method'); @@ -29,8 +28,6 @@ class TraktDebug extends Command $resp = $resp->send($method, $url); $this->line('Response (' . $resp->status() . '):' . PHP_EOL . json_encode($resp->json(), JSON_PRETTY_PRINT)); - $this->line('Config: ' . json_encode($config->get('trakt'))); - return static::SUCCESS; } diff --git a/app/Commands/TraktLogin.php b/app/Commands/TraktLogin.php index 1380ef8..1be6a85 100644 --- a/app/Commands/TraktLogin.php +++ b/app/Commands/TraktLogin.php @@ -6,14 +6,12 @@ namespace App\Commands; use App\Services\Trakt; use Illuminate\Contracts\Config\Repository; -use Illuminate\Filesystem\Filesystem; class TraktLogin extends Command { protected $signature = 'trakt:login'; protected $description = 'Login and get new token.'; - - public function handle(Trakt $trakt, Repository $config, Filesystem $files): int + public function handle(Trakt $trakt, Repository $config): int { $data = [ 'client_id' => $config->get('trakt.app_id'), @@ -33,7 +31,6 @@ class TraktLogin extends Command } $this->line("TRAKT_DEVICE_RESP='" . json_encode($body) . "'"); - $config->set('trakt.login.device', $body); $data = [ 'client_id' => $config->get('trakt.app_id'), @@ -51,8 +48,6 @@ class TraktLogin extends Command $body = $resp->json(); $this->line("TRAKT_OAUTH_RESP='" . json_encode($body) . "'"); $this->line('TRAKT_OAUTH_TOKEN=' . $body['access_token']); - $config->set('trakt.login.oauth', $body); - $files->put($config->get('trakt.path'), json_encode($config->get('trakt'), JSON_PRETTY_PRINT)); return static::SUCCESS; diff --git a/app/Commands/TraktRefreshLogin.php b/app/Commands/TraktRefreshLogin.php index 4e5acea..3baf499 100644 --- a/app/Commands/TraktRefreshLogin.php +++ b/app/Commands/TraktRefreshLogin.php @@ -6,14 +6,12 @@ namespace App\Commands; use App\Services\Trakt; use Illuminate\Contracts\Config\Repository; -use Illuminate\Filesystem\Filesystem; class TraktRefreshLogin extends Command { protected $signature = 'trakt:refresh'; protected $description = 'Refresh access token.'; - - public function handle(Trakt $trakt, Repository $config, Filesystem $files): int + public function handle(Trakt $trakt, Repository $config): int { $refresh_token = $config->get('trakt.login.oauth.refresh_token'); if (empty($refresh_token)) { @@ -42,9 +40,6 @@ class TraktRefreshLogin extends Command $this->line("TRAKT_OAUTH_RESP='" . json_encode($body) . "'"); $this->line('TRAKT_OAUTH_TOKEN=' . $body['access_token']); - $config->set('trakt.login.oauth', $body); - $files->put($config->get('trakt.path'), json_encode($config->get('trakt'), JSON_PRETTY_PRINT)); - return static::SUCCESS; } } diff --git a/composer.json b/composer.json index 728138d..c130c1b 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,7 @@ "laravel-zero/framework": "^10.0", "nunomaduro/termwind": "^1.3", "php-ffmpeg/php-ffmpeg": "^1.0", - "spatie/laravel-data": "^2.0", - "xdg/base-directory": "^1.2" + "spatie/laravel-data": "^2.0" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/composer.lock b/composer.lock index 94880d3..f09a1ad 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": "dbc82eba2362bad2cc7266710afb0827", + "content-hash": "9ebd8521e376754effa9bc94f7afbc9e", "packages": [ { "name": "brick/math", @@ -5166,76 +5166,6 @@ ], "time": "2024-09-25T14:21:43+00:00" }, - { - "name": "symfony/filesystem", - "version": "v6.4.24", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "75ae2edb7cdcc0c53766c30b0a2512b8df574bd8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/75ae2edb7cdcc0c53766c30b0a2512b8df574bd8", - "reference": "75ae2edb7cdcc0c53766c30b0a2512b8df574bd8", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8" - }, - "require-dev": { - "symfony/process": "^5.4|^6.4|^7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.24" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2025-07-10T08:14:14+00:00" - }, { "name": "symfony/finder", "version": "v6.4.24", @@ -6977,94 +6907,6 @@ "source": "https://github.com/webmozarts/assert/tree/1.12.0" }, "time": "2025-10-20T12:43:39+00:00" - }, - { - "name": "xdg/base-directory", - "version": "1.2", - "source": { - "type": "git", - "url": "https://github.com/php-xdg/base-directory.git", - "reference": "7a91de4c387e9e0d31b8ab6aa564dc85f546b381" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-xdg/base-directory/zipball/7a91de4c387e9e0d31b8ab6aa564dc85f546b381", - "reference": "7a91de4c387e9e0d31b8ab6aa564dc85f546b381", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/filesystem": "^5.4||^6.0", - "xdg/environment": "^2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Xdg\\BaseDirectory\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "ju1ius", - "email": "jules.bernable@gmail.com" - } - ], - "description": "Implementation of the XDG Base Directory Specification", - "support": { - "issues": "https://github.com/php-xdg/base-directory/issues", - "source": "https://github.com/php-xdg/base-directory/tree/1.2" - }, - "time": "2023-03-02T08:43:12+00:00" - }, - { - "name": "xdg/environment", - "version": "2.1", - "source": { - "type": "git", - "url": "https://github.com/php-xdg/environment.git", - "reference": "d626d63e902150bbf326756e4b78eea461fd7c12" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-xdg/environment/zipball/d626d63e902150bbf326756e4b78eea461fd7c12", - "reference": "d626d63e902150bbf326756e4b78eea461fd7c12", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Xdg\\Environment\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "ju1ius", - "email": "jules.bernable@gmail.com" - } - ], - "description": "An abstraction layer over environment variables.", - "keywords": [ - "environment", - "environment-variables", - "freedesktop", - "xdg" - ], - "support": { - "issues": "https://github.com/php-xdg/environment/issues", - "source": "https://github.com/php-xdg/environment/tree/2.1" - }, - "time": "2023-03-13T19:24:46+00:00" } ], "packages-dev": [ diff --git a/config/trakt.php b/config/trakt.php index 5da2121..5b91722 100644 --- a/config/trakt.php +++ b/config/trakt.php @@ -1,22 +1,11 @@ findDataPath("trakt/data.json", file_exists(...)); -if (file_exists($path)) { - $data = json_decode(file_get_contents($path), true); -} - -$data['path'] = $path; -$data = Arr::add($data, 'app_id', env('TRAKT_APP_ID')); -$data = Arr::add($data, 'app_secret', env('TRAKT_APP_SECRET')); -$data = Arr::add($data, 'redirect_uri', env('TRAKT_REDIRECT_URI', 'urn:ietf:wg:oauth:2.0:oob')); -$data['login'] = $data['login'] ?? []; -$data['login'] = Arr::add($data['login'], 'device', json_decode(env('TRAKT_DEVICE_RESP', '{}'), true)); -$data['login'] = Arr::add($data['login'], 'oauth', json_decode(env('TRAKT_OAUTH_RESP', '{}'), true)); - -return $data; +return [ + 'app_id' => env('TRAKT_APP_ID'), + 'app_secret' => env('TRAKT_APP_secret'), + 'redirect_uri' => env('TRAKT_REDIRECT_URI', 'urn:ietf:wg:oauth:2.0:oob'), + 'login' => [ + 'device' => json_decode(env('TRAKT_DEVICE_RESP', '{}}'), true), + 'oauth' => json_decode(env('TRAKT_OAUTH_RESP', '{}}'), true), + ], +];