[#1] alternative titles and started on credits
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MovieAlternativeTitle extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'iso',
|
||||||
|
'title',
|
||||||
|
'movie_id',
|
||||||
|
'type',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Service\MediaProcessing;
|
|||||||
use App\Models\Genre;
|
use App\Models\Genre;
|
||||||
use App\Models\ItemToFetchJobs;
|
use App\Models\ItemToFetchJobs;
|
||||||
use App\Models\Movie;
|
use App\Models\Movie;
|
||||||
|
use App\Models\MovieAlternativeTitle;
|
||||||
use App\Models\MovieCollection;
|
use App\Models\MovieCollection;
|
||||||
use App\Service\TMDBApi\MoviesApi;
|
use App\Service\TMDBApi\MoviesApi;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -64,18 +65,15 @@ class MovieProcessingService implements ProcessingInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$alternativeTitleModel = new MovieAlternativeTitle();
|
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||||
|
|
||||||
$movieModel = new Movie();
|
|
||||||
$movie = $movieModel->getForTmdbId($item->tmdb_id);
|
|
||||||
|
|
||||||
foreach ($alternativeTitles['titles'] as $alternativeTitle) {
|
foreach ($alternativeTitles['titles'] as $alternativeTitle) {
|
||||||
$alternativeTitleExists = $alternativeTitleModel->where('movie_id', $movie->id)
|
$alternativeTitleExists = MovieAlternativeTitle::where('movie_id', $movie->id)
|
||||||
->where('iso', $alternativeTitle['iso_3166_1'])
|
->where('iso', $alternativeTitle['iso_3166_1'])
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$alternativeTitleExists) {
|
if (!$alternativeTitleExists) {
|
||||||
$alternativeTitleModel->insert([
|
MovieAlternativeTitle::create([
|
||||||
'iso' => $alternativeTitle['iso_3166_1'],
|
'iso' => $alternativeTitle['iso_3166_1'],
|
||||||
'movie_id' => $movie->id,
|
'movie_id' => $movie->id,
|
||||||
'title' => $alternativeTitle['title'],
|
'title' => $alternativeTitle['title'],
|
||||||
@@ -84,7 +82,23 @@ class MovieProcessingService implements ProcessingInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemJob::JOB_ALTERNVATIVE_TITLES);
|
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_ALTERNVATIVE_TITLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCredits($item)
|
||||||
|
{
|
||||||
|
$tmdbCredits = $this->moviesApi->getCredits($item->tmdb_id);
|
||||||
|
|
||||||
|
if (empty($tmdbCredits)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||||
|
|
||||||
|
$this->processCast($movie, $tmdbCredits['cast'] ?? []);
|
||||||
|
$this->processCrew($movie, $tmdbCredits['crew'] ?? []);
|
||||||
|
|
||||||
|
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemJob::JOB_CREDITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processMovieCollection(int $movieId, $belongsToCollection)
|
private function processMovieCollection(int $movieId, $belongsToCollection)
|
||||||
@@ -161,4 +175,14 @@ class MovieProcessingService implements ProcessingInterface
|
|||||||
$itemToFetchJobs->remaining_jobs = $remainingJobs;
|
$itemToFetchJobs->remaining_jobs = $remainingJobs;
|
||||||
$itemToFetchJobs->save();
|
$itemToFetchJobs->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function processCast($movie, array $castList)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processCrew($movie, array $crewList)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('movie_alternative_titles', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('iso', 5)->nullable();
|
||||||
|
$table->string('title', 500)->nullable();
|
||||||
|
$table->integer('movie_id')->unsigned()->nullable();
|
||||||
|
$table->string('type', 255)->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('movie_alternative_titles');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user