[#8] fixed lots of issues on movie processing

This commit is contained in:
2025-01-04 02:13:07 +02:00
parent 70b6a7325a
commit 34d31fa2c8
6 changed files with 34 additions and 34 deletions
@@ -66,7 +66,8 @@ class MovieProcessingService implements ProcessingInterface
return; return;
} }
$tmdbMovie['slug'] = Str::slug($tmdbMovie['title']); $tmdbMovie['slug'] = Str::slug($tmdbMovie['title'].'-'.$tmdbMovie['tmdb_id']);
$tmdbMovie['release_date'] = $tmdbMovie['release_date'] ? new \DateTime($tmdbMovie['release_date']) : null;
$movieId = Movie::create($tmdbMovie); $movieId = Movie::create($tmdbMovie);
@@ -292,7 +293,7 @@ class MovieProcessingService implements ProcessingInterface
'author_avatar' => $tmdbReview['author_details']['avatar_path'], 'author_avatar' => $tmdbReview['author_details']['avatar_path'],
'author_rating' => $tmdbReview['author_details']['rating'], 'author_rating' => $tmdbReview['author_details']['rating'],
'content' => $tmdbReview['content'], 'content' => $tmdbReview['content'],
'published_at' => $tmdbReview['created_at'], 'published_at' => $tmdbReview['created_at'] ? new \DateTime($tmdbReview['created_at']) : null,
'tmdb_id' => $tmdbReview['id'], 'tmdb_id' => $tmdbReview['id'],
'tmdb_url' => $tmdbReview['url'], 'tmdb_url' => $tmdbReview['url'],
]); ]);
@@ -475,7 +476,7 @@ class MovieProcessingService implements ProcessingInterface
$user->mediaLists()->attach($list); $user->mediaLists()->attach($list);
} }
foreach ($tmdbList['items'] as $tmdbListItem) { foreach ($listDetails['items'] as $tmdbListItem) {
$mediaListItem = MediaListItem::where('media_list_id', $list->id) $mediaListItem = MediaListItem::where('media_list_id', $list->id)
->where('tmdb_id', $tmdbListItem['id']) ->where('tmdb_id', $tmdbListItem['id'])
->first(); ->first();
@@ -548,30 +549,29 @@ class MovieProcessingService implements ProcessingInterface
} }
continue; continue;
} else {
$itemToFetch = ItemToFetch::create([
'tmdb_id' => $tmdbRecommendation['id'],
'type' => ItemToFetch::TYPE_MOVIE,
]);
$jobs = ItemToFetchJobs::JOBS;
$jobs[] = "Details";
ItemToFetchJobs::create([
'tmdb_id' => $tmdbRecommendation['id'],
'type' => ItemToFetch::TYPE_MOVIE,
'remaining_jobs' => json_encode($jobs),
]);
$this->getDetails($itemToFetch);
} }
// $movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
$itemToFetch = ItemToFetch::create([
'tmdb_id' => $tmdbRecommendation['id'],
'type' => ItemToFetch::TYPE_MOVIE,
]);
$jobs = ItemToFetchJobs::JOBS;
$jobs[] = "Details";
ItemToFetchJobs::create([
'tmdb_id' => $tmdbRecommendation['id'],
'type' => ItemToFetch::TYPE_MOVIE,
'remaining_jobs' => json_encode($jobs),
]);
$this->getDetails($itemToFetch);
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
$recommendedMovie = Movie::where('tmdb_id', $tmdbRecommendation['id'])->first(); $recommendedMovie = Movie::where('tmdb_id', $tmdbRecommendation['id'])->first();
MovieRecommendation::create([ MovieRecommendation::create([
'movie_id' => $movie->id, 'movie_id' => $initialMovie->id,
'recommended_movie_id' => $recommendedMovie->id, 'recommended_movie_id' => $recommendedMovie->id,
]); ]);
} }
@@ -815,7 +815,7 @@ class MovieProcessingService implements ProcessingInterface
})->exists()) { })->exists()) {
return; return;
} else { } else {
$movie->castList()->attach($person, [ $movie->crewList()->attach($person, [
'known_for_department' => json_encode($crewPerson['known_for_department']), 'known_for_department' => json_encode($crewPerson['known_for_department']),
'job' => $crewPerson['job'], 'job' => $crewPerson['job'],
'department' => $crewPerson['department'], 'department' => $crewPerson['department'],
@@ -15,10 +15,10 @@ return new class extends Migration
$table->id(); $table->id();
$table->bigInteger('movie_id')->nullable(false); $table->bigInteger('movie_id')->nullable(false);
$table->bigInteger('person_id')->nullable(false); $table->bigInteger('person_id')->nullable(false);
$table->string('known_for_department', 500); $table->string('known_for_department', 500)->nullable();
$table->string('character', 500); $table->string('character', 500)->nullable();
$table->string('tmdb_cast_id', 500); $table->string('tmdb_cast_id', 500);
$table->integer('order'); $table->integer('order')->nullable();
$table->timestamps(); $table->timestamps();
}); });
} }
@@ -15,7 +15,7 @@ return new class extends Migration
$table->id(); $table->id();
$table->decimal('aspect_ratio', 10, 2); $table->decimal('aspect_ratio', 10, 2);
$table->integer('height'); $table->integer('height');
$table->string('iso'); $table->string('iso')->nullable();
$table->text('file_path'); $table->text('file_path');
$table->decimal('vote_average', 10, 2); $table->decimal('vote_average', 10, 2);
$table->integer('vote_count'); $table->integer('vote_count');
@@ -15,11 +15,11 @@ return new class extends Migration
$table->id(); $table->id();
$table->string('iso_3166'); $table->string('iso_3166');
$table->string('certification'); $table->string('certification');
$table->text('descriptors'); $table->text('descriptors')->nullable();
$table->string('iso_639'); $table->string('iso_639')->nullable();
$table->text('note'); $table->text('note')->nullable();
$table->date('release_date'); $table->date('release_date');
$table->integer('type'); $table->integer('type')->nullable();
$table->timestamps(); $table->timestamps();
}); });
} }
@@ -17,8 +17,8 @@ return new class extends Migration
$table->string('entity_type'); $table->string('entity_type');
$table->integer('user_id')->nullable(true); $table->integer('user_id')->nullable(true);
$table->string('author_name'); $table->string('author_name');
$table->string('author_avatar'); $table->string('author_avatar')->nullable();
$table->integer('author_rating'); $table->integer('author_rating')->nullable();
$table->text('content'); $table->text('content');
$table->datetime('published_at'); $table->datetime('published_at');
$table->string('tmdb_id'); $table->string('tmdb_id');
@@ -21,7 +21,7 @@ return new class extends Migration
$table->string('iso_3166_1', 2); $table->string('iso_3166_1', 2);
$table->string('list_type', 15); $table->string('list_type', 15);
$table->string('name', 550); $table->string('name', 550);
$table->string('poster_path', 550); $table->string('poster_path', 550)->nullable();
$table->timestamps(); $table->timestamps();
}); });
} }