[#1] added translations

This commit is contained in:
2024-12-30 03:01:12 +02:00
parent 3d7e0295ae
commit 89432548bd
3 changed files with 93 additions and 0 deletions
@@ -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();