[#1] reviews
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Service\MediaProcessing;
|
||||
|
||||
use App\Models\Comment;
|
||||
use App\Models\Genre;
|
||||
use App\Models\Image;
|
||||
use App\Models\ItemToFetchJobs;
|
||||
@@ -263,6 +264,40 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_TRANSLATIONS);
|
||||
}
|
||||
|
||||
private function getReviews($item)
|
||||
{
|
||||
$tmdbMovieReviews = $this->moviesApi->getReviews($item->tmdb_id);
|
||||
|
||||
if (empty($tmdbMovieReviews) || !isset($tmdbMovieReviews['results'])){
|
||||
return;
|
||||
}
|
||||
|
||||
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||
|
||||
foreach ($tmdbMovieReviews['results'] as $tmdbReview) {
|
||||
$existingReview = Comment::where('entity_id', $movie->id)
|
||||
->where('entity_type', Comment::TYPE_MOVIE)
|
||||
->where('tmdb_id', $tmdbReview['id'])
|
||||
->first();
|
||||
|
||||
if (!$existingReview) {
|
||||
Comment::create([
|
||||
'entity_id' => $movie->id,
|
||||
'entity_type' => Comment::TYPE_MOVIE,
|
||||
'author_name' => $tmdbReview['author'],
|
||||
'author_avatar' => $tmdbReview['author_details']['avatar_path'],
|
||||
'author_rating' => $tmdbReview['author_details']['rating'],
|
||||
'content' => $tmdbReview['content'],
|
||||
'published_at' => $tmdbReview['created_at'],
|
||||
'tmdb_id' => $tmdbReview['id'],
|
||||
'tmdb_url' => $tmdbReview['url'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_REVIEWS);
|
||||
}
|
||||
|
||||
private function processMovieCollection(int $movieId, $belongsToCollection)
|
||||
{
|
||||
$movieCollection = MovieCollection::where('tmdb_id', $belongsToCollection['id'])->first();
|
||||
|
||||
Reference in New Issue
Block a user