some progress
This commit is contained in:
@@ -58,6 +58,20 @@ class MovieProcessingService implements ProcessingInterface
|
||||
->get();
|
||||
}
|
||||
|
||||
public static function getMissingMoviesBatch(int $batch, string $job)
|
||||
{
|
||||
return ItemToFetchJobs::select('item_to_fetch_jobs.*')
|
||||
->leftJoin('movies', function ($join) {
|
||||
$join->on('movies.tmdb_id', '=', 'item_to_fetch_jobs.tmdb_id');
|
||||
})
|
||||
->whereRaw("FIND_IN_SET('".$job."', item_to_fetch_jobs.jobs)")
|
||||
->where('item_to_fetch_jobs.type', 'movie')
|
||||
->whereNull('movies.id')
|
||||
->whereNotNull('item_to_fetch_jobs.tmdb_id')
|
||||
->take($batch)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function process($item, $job)
|
||||
{
|
||||
$methodName = "get".ucfirst($job);
|
||||
@@ -66,7 +80,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
// @todo maybe raise an exception here
|
||||
return;
|
||||
}
|
||||
echo "Processing {$methodName} ".$item->tmdb_id." (".$item->id.") \n";
|
||||
echo "Processing {$methodName} ".$item->tmdb_id." (".$item->tmdb_id.") \n";
|
||||
$this->$methodName($item);
|
||||
|
||||
// maybe we should sleep for a while so we do not spam the tmdb api
|
||||
@@ -78,7 +92,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$tmdbMovie = $this->moviesApi->getMovie($item->tmdb_id);
|
||||
|
||||
if (isset($tmdbMovie['status_code']) && $tmdbMovie['status_code'] == 34) {
|
||||
echo "[ApiError-Could not be found]\n]";
|
||||
echo "[ApiError-Could not be found]\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,12 +218,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$imageExists = Image::create($image);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('images', function ($query) use ($imageExists) {
|
||||
$query->where('type', $imageExists->type)
|
||||
->where('file_path', $imageExists->file_path);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
if (!$movie->images()->where('image_id', $imageExists->id)->exists()) {
|
||||
$movie->images()->attach($imageExists);
|
||||
}
|
||||
}
|
||||
@@ -238,11 +247,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
]);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('keywords', function ($query) use ($existingKeyword) {
|
||||
$query->where('tmdb_id', $existingKeyword->tmdb_id);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
if (!$movie->keywords()->where('keyword_id', $existingKeyword->id)->exists()) {
|
||||
$movie->keywords()->attach($existingKeyword);
|
||||
}
|
||||
}
|
||||
@@ -276,11 +281,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
]);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('releaseDates', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
if (!$movie->releaseDates()->where('release_date_id', $existingReleaseDate->id)->exists()) {
|
||||
$movie->releaseDates()->attach($existingReleaseDate);
|
||||
}
|
||||
}
|
||||
@@ -452,9 +453,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$movie->whereHas('watchProviders', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
if (!$movie->watchProviders()->where('watch_provider_id', $existingWatchProvider->id)->where('locale', $locale)->exists()) {
|
||||
$movie->watchProviders()->attach($existingWatchProvider, [
|
||||
'locale' => $locale,
|
||||
'tmdb_url' => $tmdbWatchProvider['link'],
|
||||
@@ -494,11 +493,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
]);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('videos', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
if (!$movie->videos()->where('video_id', $videoExists->id)->exists()) {
|
||||
$movie->videos()->attach($videoExists);
|
||||
}
|
||||
}
|
||||
@@ -718,8 +713,6 @@ class MovieProcessingService implements ProcessingInterface
|
||||
|
||||
private function processMovieCollection(int $movieId, $belongsToCollection)
|
||||
{
|
||||
dd($belongsToCollection);
|
||||
|
||||
$movieCollection = MovieCollection::where('tmdb_id', $belongsToCollection['id'])->first();
|
||||
|
||||
if (!$movieCollection) {
|
||||
@@ -795,6 +788,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
|
||||
if (empty($remainingJobs)) {
|
||||
$itemToFetchJobs->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
// $itemToFetchJobs->remaining_jobs = $remainingJobs;
|
||||
@@ -833,7 +827,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
|
||||
$personData = array_merge($personData, [
|
||||
'biography' => $tmdbPerson['biography'],
|
||||
'birtday' => $tmdbPerson['birthday'],
|
||||
'birthday' => $tmdbPerson['birthday'],
|
||||
'deathday' => $tmdbPerson['deathday'],
|
||||
'homepage' => $tmdbPerson['homepage'],
|
||||
'imdb_id' => $tmdbPerson['imdb_id'],
|
||||
@@ -883,7 +877,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if (!empty($tmdbPerson)) {
|
||||
$personData = array_merge($personData, [
|
||||
'biography' => $tmdbPerson['biography'],
|
||||
'birtday' => $tmdbPerson['birthday'],
|
||||
'birthday' => $tmdbPerson['birthday'],
|
||||
'deathday' => $tmdbPerson['deathday'],
|
||||
'homepage' => $tmdbPerson['homepage'],
|
||||
'imdb_id' => $tmdbPerson['imdb_id'],
|
||||
|
||||
Reference in New Issue
Block a user