🚧 Submit export shows to trakt
Still very messy
This commit is contained in:
parent
f33031ed8b
commit
50c49cd0ef
8 changed files with 1615 additions and 68 deletions
31
app/Commands/TraktWatchImport.php
Normal file
31
app/Commands/TraktWatchImport.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Data\WatchData;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class TraktWatchImport extends Command
|
||||
{
|
||||
protected $signature = 'show:watch:import {files* : JSON files to import}';
|
||||
protected $description = 'Once online, sync watches from show:watch:export';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$watched = WatchData::from($this->arguments());
|
||||
$data = $watched->structuredData;
|
||||
|
||||
$headers = [
|
||||
'trakt-api-version' => 2,
|
||||
'trakt-api-key' => env('TRAKT_APP_ID'),
|
||||
'Authorization' => 'Bearer ' . env('TRAKT_OAUTH_TOKEN'),
|
||||
];
|
||||
|
||||
$this->info(sprintf('Submitting %s to trakt with headers %s', json_encode($data), json_encode($headers)));
|
||||
$response = Http::withHeaders($headers)->post('https://api.trakt.tv/sync/history', $data);
|
||||
|
||||
$this->line('Response: ' . PHP_EOL . json_encode($response->json(), JSON_PRETTY_PRINT));
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue