[#1] external ids

This commit is contained in:
2024-12-30 03:11:14 +02:00
parent fcca3d032c
commit 89f80b7937
3 changed files with 83 additions and 0 deletions
@@ -3,6 +3,7 @@
namespace App\Service\MediaProcessing;
use App\Models\Comment;
use App\Models\ExternalId;
use App\Models\Genre;
use App\Models\Image;
use App\Models\ItemToFetchJobs;
@@ -298,6 +299,31 @@ class MovieProcessingService implements ProcessingInterface
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_REVIEWS);
}
private function getExternalIds($item)
{
$externalIds = $this->moviesApi->getExternalIds($item->tmdb_id);
if (empty($externalIds)) {
return;
}
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
$externalId = ExternalId::where('entity_id', $movie->id)
->where('entity_type', ExternalId::TYPE_MOVIE)
->first();
if (!$externalId) {
$externalIds['tmdb_id'] = $externalIds['id'];
$externalIds['movie_id'] = $movie->id;
unset($externalIds['id']);
ExternalId::create($externalIds);
}
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_EXTERNAL_IDS);
}
private function processMovieCollection(int $movieId, $belongsToCollection)
{
$movieCollection = MovieCollection::where('tmdb_id', $belongsToCollection['id'])->first();