some progress on processing
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Console\Commands\ItemProcessing;
|
||||
|
||||
use App\Models\ItemToFetch;
|
||||
use App\Models\ItemToFetchJobs;
|
||||
use App\Models\Movie;
|
||||
use App\Service\MediaProcessing\FactoryService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -45,9 +47,16 @@ class FetchItemDataCommand extends Command
|
||||
|
||||
private function getBatch(string $type, int $batch, string $job)
|
||||
{
|
||||
return ItemToFetch::whereHas('jobs', function($query) use ($job){
|
||||
// if job <> Details the movie in movie table should exist
|
||||
$query = ItemToFetch::whereHas('jobs', function($query) use ($job){
|
||||
return $query->where('jobs', '<>', null)->whereRaw('FIND_IN_SET(?, jobs)', [$job]);
|
||||
})->with(['jobs'])
|
||||
})->with(['jobs']);
|
||||
|
||||
if ($job !== ItemToFetchJobs::JOB_DETAILS) {
|
||||
$query = $query->join('movies', 'movies.tmdb_id', '=', 'items_to_fetch.tmdb_id');
|
||||
}
|
||||
|
||||
return $query
|
||||
->where('type', $type)
|
||||
->take($batch)
|
||||
->get();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Forum;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CategoriesController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Forum;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostsController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Forum;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ThreadsController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Forum;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TopicsController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Forum;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Forum;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Forum;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Thread extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Forum;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Topic extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -27,6 +27,7 @@ use App\Models\WatchProvider;
|
||||
use App\Service\TMDBApi\ListApi;
|
||||
use App\Service\TMDBApi\MoviesApi;
|
||||
use App\Service\TMDBApi\PersonApi;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MovieProcessingService implements ProcessingInterface
|
||||
@@ -53,7 +54,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
// @todo maybe raise an exception here
|
||||
return;
|
||||
}
|
||||
|
||||
echo "Processing {$methodName} ".$item->tmdb_id."\n";
|
||||
$this->$methodName($item);
|
||||
}
|
||||
|
||||
@@ -62,6 +63,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$tmdbMovie = $this->moviesApi->getMovie($item->tmdb_id);
|
||||
$tmdbMovie['tmdb_id'] = $tmdbMovie['id'];
|
||||
|
||||
Log::channel('fetch_export_items_details')->info("Processing TmdbId ".$tmdbMovie['tmdb_id']);
|
||||
|
||||
$movie = Movie::where('tmdb_id', $tmdbMovie['tmdb_id'])->first();
|
||||
|
||||
if($movie) {
|
||||
@@ -74,18 +77,22 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$movieId = Movie::create($tmdbMovie);
|
||||
|
||||
if (!empty($tmdbMovie['belongs_to_collection'])) {
|
||||
Log::channel('fetch_export_items_details')->info("Processing collections for ".$tmdbMovie['tmdb_id']);
|
||||
$this->processMovieCollection($movieId->id, $tmdbMovie['belongs_to_collection']);
|
||||
}
|
||||
|
||||
if (!empty($tmdbMovie['genres'])) {
|
||||
Log::channel('fetch_export_items_details')->info("Processing genres for ".$tmdbMovie['tmdb_id']);
|
||||
$this->processMovieGenres($movieId->id, $tmdbMovie['genres']);
|
||||
}
|
||||
|
||||
if (!empty($tmdbMovie['production_companies'])) {
|
||||
Log::channel('fetch_export_items_details')->info("Processing production companies ".$tmdbMovie['tmdb_id']);
|
||||
$this->processProductionCompanies($movieId->id, $tmdbMovie['production_companies']);
|
||||
}
|
||||
|
||||
if (!empty($tmdbMovie['production_countries'])) {
|
||||
Log::channel('fetch_export_items_details')->info("Processing production countries ".$tmdbMovie['tmdb_id']);
|
||||
$this->processProductionCountries($movieId->id, $tmdbMovie['production_countries']);
|
||||
}
|
||||
|
||||
@@ -96,6 +103,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
{
|
||||
$alternativeTitles = $this->moviesApi->getAlternativeTitles($item->tmdb_id);
|
||||
|
||||
Log::channel('fetch_export_items_alternative_titles')->info("Processing TmdbId ".$item->tmdb_id);
|
||||
|
||||
if (empty($alternativeTitles) || !isset($alternativeTitles['titles'])) {
|
||||
return;
|
||||
}
|
||||
@@ -123,6 +132,9 @@ class MovieProcessingService implements ProcessingInterface
|
||||
private function getCredits($item)
|
||||
{
|
||||
echo "Credits for TMDBID ".$item->tmdb_id." \n";
|
||||
|
||||
Log::channel('fetch_export_items_credits')->info("Credits for TMDBID ".$item->tmdb_id);
|
||||
|
||||
$tmdbCredits = $this->moviesApi->getCredits($item->tmdb_id);
|
||||
|
||||
if (empty($tmdbCredits)) {
|
||||
@@ -132,7 +144,13 @@ class MovieProcessingService implements ProcessingInterface
|
||||
|
||||
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||
|
||||
if (null === $movie) {
|
||||
echo "No movie for TMDB id ".$item->tmdb_id."\n";
|
||||
}
|
||||
|
||||
Log::channel('fetch_export_items_credits')->info("Processing cast for TMDBID ".$item->tmdb_id);
|
||||
$this->processCast($movie, $tmdbCredits['cast'] ?? []);
|
||||
Log::channel('fetch_export_items_credits')->info("Processing crew for TMDBID ".$item->tmdb_id);
|
||||
$this->processCrew($movie, $tmdbCredits['crew'] ?? []);
|
||||
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_CREDITS);
|
||||
@@ -790,7 +808,7 @@ class MovieProcessingService implements ProcessingInterface
|
||||
|
||||
private function processCrew($movie, array $crewList)
|
||||
{
|
||||
if (empty($crewList)) {
|
||||
if (empty($crewList) || $movie === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -826,11 +844,9 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$person = Person::create($personData);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('crewList', function ($query) use ($person) {
|
||||
$query->where('tmdb_id', '=', $person->tmdb_id);
|
||||
if (!$movie->whereHas('crewList', function ($query) use ($person) {
|
||||
$query->where('person_id', '=', $person->id);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
$movie->crewList()->attach($person, [
|
||||
'known_for_department' => json_encode($crewPerson['known_for_department']),
|
||||
'job' => $crewPerson['job'],
|
||||
|
||||
Reference in New Issue
Block a user