[#1] processing videos and livewire
This commit is contained in:
@@ -6,21 +6,10 @@ use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Homepage\Movies;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class LatestTrailersComponent extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.homepage.movies.latest-trailers-component');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Homepage\Movies;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class NewMoviesComponent extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.homepage.movies.new-movies-component');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Homepage\Movies;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class UpcomingMoviesComponent extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.homepage.movies.upcoming-movies-component');
|
||||
}
|
||||
}
|
||||
@@ -67,4 +67,9 @@ class Movie extends Model
|
||||
{
|
||||
return $this->belongsToMany(WatchProvider::class, 'movie_watch_providers', 'movie_id', 'watch_provider_id');
|
||||
}
|
||||
|
||||
public function videos()
|
||||
{
|
||||
return $this->belongsToMany(Video::class, 'movie_videos', 'movie_id', 'video_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Video extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'iso_639',
|
||||
'iso_3166',
|
||||
'name',
|
||||
'key',
|
||||
'site',
|
||||
'size',
|
||||
'type',
|
||||
'official',
|
||||
'published_at',
|
||||
'tmdb_id',
|
||||
];
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use App\Models\MovieCollection;
|
||||
use App\Models\Person;
|
||||
use App\Models\ReleaseDate;
|
||||
use App\Models\Translation;
|
||||
use App\Models\Video;
|
||||
use App\Models\WatchProvider;
|
||||
use App\Service\TMDBApi\MoviesApi;
|
||||
use App\Service\TMDBApi\PersonApi;
|
||||
@@ -143,10 +144,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$query->where('type', $imageExists->type)
|
||||
->where('file_path', $imageExists->file_path);
|
||||
})->exists()) {
|
||||
echo "Movie has image | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie does not have image | ";
|
||||
$movie->images()->attach($imageExists);
|
||||
}
|
||||
}
|
||||
@@ -178,10 +177,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('keywords', function ($query) use ($existingKeyword) {
|
||||
$query->where('tmdb_id', $existingKeyword->tmdb_id);
|
||||
})->exists()) {
|
||||
echo "Movie has keyword | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie does not have keyword | ";
|
||||
$movie->keywords()->attach($existingKeyword);
|
||||
}
|
||||
}
|
||||
@@ -194,14 +191,11 @@ class MovieProcessingService implements ProcessingInterface
|
||||
$tmdbReleases = $this->moviesApi->getReleases($item->tmdb_id);
|
||||
|
||||
if (empty($tmdbReleases) || !isset($tmdbReleases['countries'])) {
|
||||
echo "[E] Movie ".$item->tmdb_id ." Releases ".json_encode($tmdbReleases)."\n\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||
|
||||
echo "Movie ".$movie->id ." Releases ".json_encode($tmdbReleases)."\n\n";
|
||||
|
||||
foreach ($tmdbReleases['countries'] as $tmdbRelease) {
|
||||
$existingReleaseDate = ReleaseDate::where('iso_3166', $tmdbRelease['iso_3166_1'])
|
||||
->where('release_date', $tmdbRelease['release_date'])
|
||||
@@ -221,10 +215,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('releaseDates', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
echo "Movie has release date | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie does not have release date | ";
|
||||
$movie->releaseDates()->attach($existingReleaseDate);
|
||||
}
|
||||
}
|
||||
@@ -365,17 +357,56 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('watchProviders', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
echo "Movie has watch provider | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie does not have watch provider | ";
|
||||
$movie->watchProviders()->attach($existingWatchProvider, [
|
||||
'locale' => $locale,
|
||||
'tmdb_url' => $tmdbWatchProvider['link'],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_WATCH_PROVIDERS);
|
||||
}
|
||||
|
||||
private function getVideos($item)
|
||||
{
|
||||
$movie = Movie::where('tmdb_id', $item->tmdb_id)->first();
|
||||
|
||||
$tmdbVideos = $this->moviesApi->getVideos($item->tmdb_id);
|
||||
|
||||
if (empty($tmdbVideos) || empty($tmdbVideos['results'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($tmdbVideos['results'] as $tmdbVideo) {
|
||||
$videoExists = Video::where('tmdb_id', $tmdbVideo['id'])->first();
|
||||
|
||||
if (!$videoExists) {
|
||||
$videoExists = Video::create([
|
||||
'iso_639' => $tmdbVideo['iso_639_1'],
|
||||
'iso_3166' => $tmdbVideo['iso_3166_1'],
|
||||
'name' => $tmdbVideo['name'],
|
||||
'key' => $tmdbVideo['key'],
|
||||
'site' => $tmdbVideo['site'],
|
||||
'size' => $tmdbVideo['size'],
|
||||
'type' => $tmdbVideo['type'],
|
||||
'official' => $tmdbVideo['official'],
|
||||
'published_at' => $tmdbVideo['published_at'],
|
||||
'tmdb_id' => $tmdbVideo['id'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($movie->whereHas('videos', function ($query) use ($movie) {
|
||||
$query->where('movie_id', $movie->id);
|
||||
})->exists()) {
|
||||
return;
|
||||
} else {
|
||||
$movie->videos()->attach($videoExists);
|
||||
}
|
||||
}
|
||||
|
||||
$this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_VIDEOS);
|
||||
}
|
||||
|
||||
private function processMovieCollection(int $movieId, $belongsToCollection)
|
||||
@@ -397,10 +428,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('collections', function ($query) use ($movieCollection) {
|
||||
$query->where('tmdb_id', '=', $movieCollection->tmdb_id);
|
||||
})->exists()) {
|
||||
echo "Movie is in the collection";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie is not in the collection";
|
||||
$movie->collections()->attach($movieCollection);
|
||||
}
|
||||
|
||||
@@ -427,10 +456,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('genres', function ($query) use ($genre) {
|
||||
$query->where('tmdb_id', '=', $genre->tmdb_id);
|
||||
})->exists()) {
|
||||
echo "Movie is in the genre";
|
||||
return;
|
||||
} else {
|
||||
echo "Movie is not in the genre";
|
||||
$movie->genres()->attach($genre);
|
||||
}
|
||||
}
|
||||
@@ -494,10 +521,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('castList', function ($query) use ($person) {
|
||||
$query->where('tmdb_id', '=', $person->tmdb_id);
|
||||
})->exists()) {
|
||||
echo "Person is in cast | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Person is not in cast |";
|
||||
$movie->castList()->attach($person, [
|
||||
'known_for_department' => $castPerson['known_for_department'],
|
||||
'character' => $castPerson['character'],
|
||||
@@ -549,10 +574,8 @@ class MovieProcessingService implements ProcessingInterface
|
||||
if ($movie->whereHas('crewList', function ($query) use ($person) {
|
||||
$query->where('tmdb_id', '=', $person->tmdb_id);
|
||||
})->exists()) {
|
||||
echo "Person is in crew | ";
|
||||
return;
|
||||
} else {
|
||||
echo "Person is not in crew |";
|
||||
$movie->castList()->attach($person, [
|
||||
'known_for_department' => json_encode($crewPerson['known_for_department']),
|
||||
'job' => $crewPerson['job'],
|
||||
|
||||
+2
-1
@@ -10,10 +10,11 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"ext-zlib": "*",
|
||||
"laravel/framework": "^11.31",
|
||||
"laravel/tinker": "^2.9",
|
||||
"laravel/ui": "^4.6",
|
||||
"ext-zlib": "*"
|
||||
"livewire/livewire": "^3.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
Generated
+79
-2
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f70b6bfc17538a9703666cf04bbb5ccf",
|
||||
"content-hash": "4e7e2781a95eda3eb8e36b6b04f4625f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@@ -2069,6 +2069,82 @@
|
||||
],
|
||||
"time": "2024-12-08T08:18:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "livewire/livewire",
|
||||
"version": "v3.5.18",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/livewire/livewire.git",
|
||||
"reference": "62f0fa6b340a467c25baa590a567d9a134b357da"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/livewire/livewire/zipball/62f0fa6b340a467c25baa590a567d9a134b357da",
|
||||
"reference": "62f0fa6b340a467c25baa590a567d9a134b357da",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": "^10.0|^11.0",
|
||||
"illuminate/routing": "^10.0|^11.0",
|
||||
"illuminate/support": "^10.0|^11.0",
|
||||
"illuminate/validation": "^10.0|^11.0",
|
||||
"laravel/prompts": "^0.1.24|^0.2|^0.3",
|
||||
"league/mime-type-detection": "^1.9",
|
||||
"php": "^8.1",
|
||||
"symfony/console": "^6.0|^7.0",
|
||||
"symfony/http-kernel": "^6.2|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"calebporzio/sushi": "^2.1",
|
||||
"laravel/framework": "^10.15.0|^11.0",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"orchestra/testbench": "^8.21.0|^9.0",
|
||||
"orchestra/testbench-dusk": "^8.24|^9.1",
|
||||
"phpunit/phpunit": "^10.4",
|
||||
"psy/psysh": "^0.11.22|^0.12"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"Livewire": "Livewire\\Livewire"
|
||||
},
|
||||
"providers": [
|
||||
"Livewire\\LivewireServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Livewire\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Caleb Porzio",
|
||||
"email": "calebporzio@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A front-end framework for Laravel.",
|
||||
"support": {
|
||||
"issues": "https://github.com/livewire/livewire/issues",
|
||||
"source": "https://github.com/livewire/livewire/tree/v3.5.18"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/livewire",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-23T15:05:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "3.8.1",
|
||||
@@ -8141,7 +8217,8 @@
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^8.2"
|
||||
"php": "^8.2",
|
||||
"ext-zlib": "*"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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('videos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('iso_639', 5)->nullable();
|
||||
$table->string('iso_3166', 5)->nullable();
|
||||
$table->string('name', 500)->nullable();
|
||||
$table->string('key')->nullable();
|
||||
$table->string('site', 50)->nullable();
|
||||
$table->integer('size')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->boolean('official');
|
||||
$table->dateTime('published_at');
|
||||
$table->string('tmdb_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('videos');
|
||||
}
|
||||
};
|
||||
@@ -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('movie_videos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('movie_id');
|
||||
$table->unsignedBigInteger('video_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('movie_videos');
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,9 @@
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
@livewire(App\Livewire\Homepage\Movies\LatestTrailersComponent::class)
|
||||
@livewire(App\Livewire\Homepage\Movies\NewMoviesComponent::class)
|
||||
@livewire(App\Livewire\Homepage\Movies\UpcomingMoviesComponent::class)
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Dashboard') }}</div>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
<!-- Scripts -->
|
||||
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
|
||||
@livewireStyles
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
@@ -76,5 +77,6 @@
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
@livewireScripts
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
latest trailers
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
{{-- If you look to others for fulfillment, you will never truly be fulfilled. --}}
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
{{-- In work, do what you enjoy. --}}
|
||||
</div>
|
||||
+7
-1
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Console\Commands\ItemProcessing\FetchItemDataCommand;
|
||||
use App\Console\Commands\TmdbFetch\FetchExportCommand;
|
||||
use App\Console\Commands\TmdbFetch\FetchExportItemsCommand;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schedule;
|
||||
@@ -13,4 +15,8 @@ Artisan::command('inspire', function () {
|
||||
Schedule::command(FetchExportCommand::class, ['type', 'movies'])->weeklyOn(6, '8:00');
|
||||
Schedule::command(FetchExportCommand::class, ['type', 'tv_series'])->weeklyOn(6, '9:00');
|
||||
|
||||
//Schedule::command('emails:send Taylor --force')->daily();
|
||||
Schedule::command(FetchExportItemsCommand::class, ['type', 'movie'])->twiceDaily(17,19);
|
||||
Schedule::command(FetchExportItemsCommand::class, ['type', 'tv_series'])->twiceDaily(17,19);
|
||||
|
||||
// fetch items data
|
||||
Schedule::command(FetchItemDataCommand::class)->twiceDaily(18,20);
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
//Route::get('/', function () {
|
||||
// return view('welcome');
|
||||
//});
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||
Route::get('/', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||
|
||||
Reference in New Issue
Block a user