some progress on processing

This commit is contained in:
2025-01-27 22:40:26 +02:00
parent e5df18f43e
commit b4df3c216e
17 changed files with 346 additions and 8 deletions
@@ -3,6 +3,8 @@
namespace App\Console\Commands\ItemProcessing; namespace App\Console\Commands\ItemProcessing;
use App\Models\ItemToFetch; use App\Models\ItemToFetch;
use App\Models\ItemToFetchJobs;
use App\Models\Movie;
use App\Service\MediaProcessing\FactoryService; use App\Service\MediaProcessing\FactoryService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@@ -45,9 +47,16 @@ class FetchItemDataCommand extends Command
private function getBatch(string $type, int $batch, string $job) 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]); 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) ->where('type', $type)
->take($batch) ->take($batch)
->get(); ->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
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Models\Forum;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Models\Forum;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Models\Forum;
use Illuminate\Database\Eloquent\Model;
class Thread extends Model
{
//
}
+10
View File
@@ -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\ListApi;
use App\Service\TMDBApi\MoviesApi; use App\Service\TMDBApi\MoviesApi;
use App\Service\TMDBApi\PersonApi; use App\Service\TMDBApi\PersonApi;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class MovieProcessingService implements ProcessingInterface class MovieProcessingService implements ProcessingInterface
@@ -53,7 +54,7 @@ class MovieProcessingService implements ProcessingInterface
// @todo maybe raise an exception here // @todo maybe raise an exception here
return; return;
} }
echo "Processing {$methodName} ".$item->tmdb_id."\n";
$this->$methodName($item); $this->$methodName($item);
} }
@@ -62,6 +63,8 @@ class MovieProcessingService implements ProcessingInterface
$tmdbMovie = $this->moviesApi->getMovie($item->tmdb_id); $tmdbMovie = $this->moviesApi->getMovie($item->tmdb_id);
$tmdbMovie['tmdb_id'] = $tmdbMovie['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(); $movie = Movie::where('tmdb_id', $tmdbMovie['tmdb_id'])->first();
if($movie) { if($movie) {
@@ -74,18 +77,22 @@ class MovieProcessingService implements ProcessingInterface
$movieId = Movie::create($tmdbMovie); $movieId = Movie::create($tmdbMovie);
if (!empty($tmdbMovie['belongs_to_collection'])) { 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']); $this->processMovieCollection($movieId->id, $tmdbMovie['belongs_to_collection']);
} }
if (!empty($tmdbMovie['genres'])) { if (!empty($tmdbMovie['genres'])) {
Log::channel('fetch_export_items_details')->info("Processing genres for ".$tmdbMovie['tmdb_id']);
$this->processMovieGenres($movieId->id, $tmdbMovie['genres']); $this->processMovieGenres($movieId->id, $tmdbMovie['genres']);
} }
if (!empty($tmdbMovie['production_companies'])) { 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']); $this->processProductionCompanies($movieId->id, $tmdbMovie['production_companies']);
} }
if (!empty($tmdbMovie['production_countries'])) { 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']); $this->processProductionCountries($movieId->id, $tmdbMovie['production_countries']);
} }
@@ -96,6 +103,8 @@ class MovieProcessingService implements ProcessingInterface
{ {
$alternativeTitles = $this->moviesApi->getAlternativeTitles($item->tmdb_id); $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'])) { if (empty($alternativeTitles) || !isset($alternativeTitles['titles'])) {
return; return;
} }
@@ -123,6 +132,9 @@ class MovieProcessingService implements ProcessingInterface
private function getCredits($item) private function getCredits($item)
{ {
echo "Credits for TMDBID ".$item->tmdb_id." \n"; 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); $tmdbCredits = $this->moviesApi->getCredits($item->tmdb_id);
if (empty($tmdbCredits)) { if (empty($tmdbCredits)) {
@@ -132,7 +144,13 @@ class MovieProcessingService implements ProcessingInterface
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first(); $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'] ?? []); $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->processCrew($movie, $tmdbCredits['crew'] ?? []);
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_CREDITS); $this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_CREDITS);
@@ -790,7 +808,7 @@ class MovieProcessingService implements ProcessingInterface
private function processCrew($movie, array $crewList) private function processCrew($movie, array $crewList)
{ {
if (empty($crewList)) { if (empty($crewList) || $movie === null) {
return; return;
} }
@@ -826,11 +844,9 @@ class MovieProcessingService implements ProcessingInterface
$person = Person::create($personData); $person = Person::create($personData);
} }
if ($movie->whereHas('crewList', function ($query) use ($person) { if (!$movie->whereHas('crewList', function ($query) use ($person) {
$query->where('tmdb_id', '=', $person->tmdb_id); $query->where('person_id', '=', $person->id);
})->exists()) { })->exists()) {
return;
} else {
$movie->crewList()->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'],
+103
View File
@@ -126,7 +126,110 @@ return [
'emergency' => [ 'emergency' => [
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
], ],
'fetch_export' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export.log'),
'level' => 'info',
],
'fetch_export_items_details' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_details.log'),
'level' => 'info',
],
'fetch_export_items_credits' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_credits.log'),
'level' => 'info',
],
'fetch_export_items_alternative_titles' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_alternative_titles.log'),
'level' => 'info',
],
'fetch_export_items_images' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_images.log'),
'level' => 'info',
],
'fetch_export_items_keywords' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_keywords.log'),
'level' => 'info',
],
'fetch_export_items_releases' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_releases.log'),
'level' => 'info',
],
'fetch_export_items_translations' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_translations.log'),
'level' => 'info',
],
'fetch_export_items_similar' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_similar.log'),
'level' => 'info',
],
'fetch_export_items_recommendations' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_recommendations.log'),
'level' => 'info',
],
'fetch_export_items_reviews' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_reviews.log'),
'level' => 'info',
],
'fetch_export_items_lists' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_lists.log'),
'level' => 'info',
],
'fetch_export_items_changes' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_changes.log'),
'level' => 'info',
],
'fetch_export_items_videos' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_videos.log'),
'level' => 'info',
],
'fetch_export_items_watch_providers' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_watch_providers.log'),
'level' => 'info',
],
'fetch_export_items_external_ids' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_external_ids.log'),
'level' => 'info',
],
'fetch_export_items_content_ratings' => [
'driver' => 'stack',
'channels' => ['daily'],
'path' => storage_path('logs/fetch_export_items_content_ratings.log'),
'level' => 'info',
],
], ],
]; ];
@@ -0,0 +1,32 @@
<?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('forum_categories', function (Blueprint $table) {
$table->id();
$table->integer('order')->default(0);
$table->string('name');
$table->string('slug');
$table->string('icon');
$table->text('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('forum_categories');
}
};
@@ -0,0 +1,33 @@
<?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('forum_threads', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id');
$table->string('name');
$table->string('slug');
$table->string('icon');
$table->text('description');
$table->integer('order')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('forum_threads');
}
};
@@ -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('forum_topics', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->enum('status', ['open', 'closed', 'sticky']);
$table->unsignedBigInteger('user_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('forum_topics');
}
};
@@ -0,0 +1,29 @@
<?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('forum_posts', function (Blueprint $table) {
$table->id();
$table->text('content');
$table->unsignedBigInteger('user_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('forum_posts');
}
};
+1
View File
@@ -11,6 +11,7 @@
<li class="nav-item"><a href="{{ route('movie.index') }}" class="nav-link">Movies</a></li> <li class="nav-item"><a href="{{ route('movie.index') }}" class="nav-link">Movies</a></li>
<li class="nav-item"><a href="#" class="nav-link">Tv Shows</a></li> <li class="nav-item"><a href="#" class="nav-link">Tv Shows</a></li>
<li class="nav-item"><a href="#" class="nav-link">Celebrities</a></li> <li class="nav-item"><a href="#" class="nav-link">Celebrities</a></li>
<li class="nav-item"><a href="#" class="nav-link">Forums</a></li>
<li class="nav-item"><a href="#" class="nav-link">Contact</a></li> <li class="nav-item"><a href="#" class="nav-link">Contact</a></li>
@guest @guest
@if (Route::has('login')) @if (Route::has('login'))
Binary file not shown.