[#1] added translations
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Translation extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'movie_id',
|
||||
'iso_3166',
|
||||
'iso_639',
|
||||
'name',
|
||||
'english_name',
|
||||
'homepage',
|
||||
'overview',
|
||||
'runtime',
|
||||
'tagline',
|
||||
'title',
|
||||
];
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use App\Models\MovieAlternativeTitle;
|
||||
use App\Models\MovieCollection;
|
||||
use App\Models\Person;
|
||||
use App\Models\ReleaseDate;
|
||||
use App\Models\Translation;
|
||||
use App\Service\TMDBApi\MoviesApi;
|
||||
use App\Service\TMDBApi\PersonApi;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -228,6 +229,40 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_RELEASES);
|
||||
}
|
||||
|
||||
private function getTranslations($item)
|
||||
{
|
||||
$tmdbMovieTranslations = $this->moviesApi->getTranslations($item->tmdb_id);
|
||||
|
||||
if (!$tmdbMovieTranslations || !isset($tmdbMovieTranslations['translations'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||
|
||||
foreach ($tmdbMovieTranslations['translations'] as $tmdbTranslation) {
|
||||
$existingTranslation = Translation::where('movie_id', $movie->id)
|
||||
->where('name', $tmdbTranslation['name'])
|
||||
->first();
|
||||
|
||||
if (!$existingTranslation) {
|
||||
Translation::create([
|
||||
'movie_id' => $movie->id,
|
||||
'iso_3166' => $tmdbTranslation['iso_3166_1'],
|
||||
'iso_639' => $tmdbTranslation['iso_639_1'],
|
||||
'name' => $tmdbTranslation['name'],
|
||||
'english_name' => $tmdbTranslation['english_name'],
|
||||
'homepage' => $tmdbTranslation['data']['homepage'],
|
||||
'overview' => $tmdbTranslation['data']['overview'],
|
||||
'runtime' => $tmdbTranslation['data']['runtime'],
|
||||
'tagline' => $tmdbTranslation['data']['tagline'],
|
||||
'title' => $tmdbTranslation['data']['title'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_TRANSLATIONS);
|
||||
}
|
||||
|
||||
private function processMovieCollection(int $movieId, $belongsToCollection)
|
||||
{
|
||||
$movieCollection = MovieCollection::where('tmdb_id', $belongsToCollection['id'])->first();
|
||||
|
||||
Reference in New Issue
Block a user