season
This commit is contained in:
parent
2ecabeca97
commit
6eab26d677
5 changed files with 50 additions and 59 deletions
|
@ -14,7 +14,7 @@
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Supports\Traits\Helpers;
|
use App\Supports\Helpers;
|
||||||
use App\Http\Requests\MoreMoviesRequest;
|
use App\Http\Requests\MoreMoviesRequest;
|
||||||
use App\Http\Resources\MoreTitles;
|
use App\Http\Resources\MoreTitles;
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug =
|
||||||
$id = self::decodeId($id);
|
$id = self::decodeId($id);
|
||||||
$show = $tmdb->getShow($id);
|
$show = $tmdb->getShow($id);
|
||||||
|
|
||||||
$data = $this->formatTmdbShow($show);
|
|
||||||
if (isset($season)) {
|
if (isset($season)) {
|
||||||
|
|
||||||
$season_number = (int)$season;
|
$season_number = (int)$season;
|
||||||
|
@ -72,10 +71,8 @@ public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug =
|
||||||
$season = $tmdb->getSeason($show['id'], $season_number);
|
$season = $tmdb->getSeason($show['id'], $season_number);
|
||||||
$season = $this->formatTmdbSeason($season, $show);
|
$season = $this->formatTmdbSeason($season, $show);
|
||||||
}
|
}
|
||||||
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
|
// $airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
|
||||||
// dd($data);
|
return $show;
|
||||||
// $data['meta']['title'] = 'Watch ' . $movie['title'];
|
|
||||||
return $data;
|
|
||||||
};
|
};
|
||||||
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
|
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
|
||||||
// dd($results);
|
// dd($results);
|
||||||
|
@ -101,54 +98,34 @@ public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug =
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function episode(TmdbClient $tmdb, ApiClient $api, AdsController $adsController, int $id, int $season, int $episode, string $slug)
|
public function episode(TmdbClient $tmdb, ApiClient $api, AdsController $adsController, int $id, string $slug, int $season, int $episode)
|
||||||
{
|
{
|
||||||
$similar = [];
|
$similar = [];
|
||||||
$season_number = $season;
|
$season_number = $season;
|
||||||
$episode_number = $episode;
|
$episode_number = $episode;
|
||||||
$call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){
|
$call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){
|
||||||
$id = self::decodeId($id);
|
$id = self::decodeId($id);
|
||||||
$show = $tmdb->getShow($id);
|
$data = $tmdb->getShow($id);
|
||||||
$data = $this->formatTmdbShow($show);
|
$season = $tmdb->getSeason($data['id'], $season_number);
|
||||||
$season = $tmdb->getSeason($show['id'], $season_number);
|
$season = $this->formatTmdbSeason($season, $data);
|
||||||
$season = $this->formatTmdbSeason($season);
|
$episode = $tmdb->getEpisode($data['id'], $season_number, $episode_number);
|
||||||
$episode = $tmdb->getEpisode($show['id'], $season_number, $episode_number);
|
|
||||||
$episode = $this->formatTmdbEpisode($episode);
|
$episode = $this->formatTmdbEpisode($episode);
|
||||||
|
|
||||||
// $episode
|
|
||||||
// dd($data);
|
|
||||||
// $data['meta']['title'] = 'Watch ' . $movie['title'];
|
|
||||||
return $data;
|
return $data;
|
||||||
};
|
};
|
||||||
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
|
$show = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
|
||||||
// dd($results);
|
// dd($results);
|
||||||
$meta['schema'] = SchemaBuilder::getShowEpisodeSchema($results, $season, $episode);
|
$meta['schema'] = SchemaBuilder::getShowEpisodeSchema($show, $season, $episode);
|
||||||
$data = $results;
|
|
||||||
$top = $this->getTopContent($tmdb, $api);
|
// load episode background path if available
|
||||||
// dd($data);
|
$show['backdrop_path'] = $episode['still_path'] ?? $show['backdrop_path'];
|
||||||
// dd($upcoming);
|
|
||||||
$meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{EPISODE}', '{EPISODE_TITLE}'], [$data['title'], $season_number, $episode_number, $episode['name']], config('site.shows.detail_episode.title'));
|
$meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{EPISODE}', '{EPISODE_TITLE}'], [$show['title'], $season_number, $episode_number, $episode['name']], config('site.shows.detail_episode.title'));
|
||||||
$meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}', '{EPISODE}'], [$episode['overview'], $season_number, $episode_number], config('site.shows.detail_episode.description')), 150);
|
$meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}', '{EPISODE}'], [$episode['overview'], $season_number, $episode_number], config('site.shows.detail_episode.description')), 150);
|
||||||
$meta['image'] = $episode['backdrop'];
|
$meta['image'] = $episode['backdrop'];
|
||||||
$meta['keywords'] = config('site.shows.detail_episode.keywords');
|
$meta['keywords'] = config('site.shows.detail_episode.keywords');
|
||||||
|
|
||||||
|
$is_show_page = false;
|
||||||
// dd($season);
|
return view('show', compact('show', 'season', 'episode', 'meta', 'is_show_page'));
|
||||||
if (defined('SHOULD_PRERENDER')) {
|
|
||||||
return view('prerender.show', compact('data', 'season', 'episode', 'meta', 'top'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$modal = $adsController->shouldGetModal(request()->headers->get('cf-ipcountry', 'AU'));
|
|
||||||
|
|
||||||
$meta = self::encodeForInertia($meta ?? []) ;
|
|
||||||
$top = self::encodeForInertia($top);
|
|
||||||
$data = self::encodeForInertia($data ?? []);
|
|
||||||
$season = self::encodeForInertia($season ?? []);
|
|
||||||
$episode = self::encodeForInertia($episode ?? []);
|
|
||||||
|
|
||||||
|
|
||||||
return Inertia::render('Show', compact('data', 'season', 'episode', 'meta', 'top', 'modal'));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ public static function getShowSeasonSchema($show, $season): array
|
||||||
return Schema::person()->name($actor['name'])->image($actor['image']);
|
return Schema::person()->name($actor['name'])->image($actor['image']);
|
||||||
})->values()->all();
|
})->values()->all();
|
||||||
$movieSchema->actor($actors);
|
$movieSchema->actor($actors);
|
||||||
$directors = collect($season['crew'])->filter(fn ($director) => Str::of($director['as'])->contains('producer', true))->map(function ($director) {
|
$directors = collect($season['crew']['producers'])->map(function ($director) {
|
||||||
return Schema::person()->name($director['name'])->image($director['image']);
|
return Schema::person()->name($director['name'])->image($director['image']);
|
||||||
})->values()->all();
|
})->values()->all();
|
||||||
$movieSchema->producer($directors);
|
$movieSchema->producer($directors);
|
||||||
|
|
|
@ -19,14 +19,11 @@ protected function getPageLabel(?string $label)
|
||||||
switch ($label) {
|
switch ($label) {
|
||||||
case 'pagination.previous':
|
case 'pagination.previous':
|
||||||
return 'Previous';
|
return 'Previous';
|
||||||
break;
|
|
||||||
case 'pagination.next':
|
case 'pagination.next':
|
||||||
return 'Next';
|
return 'Next';
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $label;
|
return $label;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,10 +127,10 @@ public function formatTmdbSeason($data, $showData):array
|
||||||
$show['overview'] = $data['overview'] !== '' ? $data['overview'] : $showData['overview'];
|
$show['overview'] = $data['overview'] !== '' ? $data['overview'] : $showData['overview'];
|
||||||
$show['cast'] = $this->getCast($show['credits']['cast'] ?? $showData['credits']['cast'] ?? [], 8);
|
$show['cast'] = $this->getCast($show['credits']['cast'] ?? $showData['credits']['cast'] ?? [], 8);
|
||||||
$show['crew']['producers'] = $this->getCrew($show['credits']['crew'] ?? $showData['credits']['crew'] ?? [], 8);
|
$show['crew']['producers'] = $this->getCrew($show['credits']['crew'] ?? $showData['credits']['crew'] ?? [], 8);
|
||||||
$show['air_date'] = Helpers::formatReleaseDate($data['air_date']);
|
$show['air_date'] = self::formatReleaseDate($data['air_date']);
|
||||||
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 230, 345);
|
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 230, 345);
|
||||||
$show['episodes'] = collect($show['episodes'])->map(function($episode){
|
$show['episodes'] = collect($show['episodes'])->map(function($episode){
|
||||||
$episode['air_date'] = Helpers::formatReleaseDate($episode['air_date']);
|
$episode['air_date'] = self::formatReleaseDate($episode['air_date']);
|
||||||
$episode['label'] = /* 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT). 'E'.*/str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
|
$episode['label'] = /* 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT). 'E'.*/str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
|
||||||
$episode['backdrop'] = $this->getImageUrl($episode['still_path'], 'w1280', 1280, 720);
|
$episode['backdrop'] = $this->getImageUrl($episode['still_path'], 'w1280', 1280, 720);
|
||||||
unset($episode['still_path']);
|
unset($episode['still_path']);
|
||||||
|
@ -154,11 +151,10 @@ public function formatTmdbEpisode($data):array
|
||||||
|
|
||||||
$episode['cast'] = $this->getCast($episode['credits']['cast'] ?? [], 8);
|
$episode['cast'] = $this->getCast($episode['credits']['cast'] ?? [], 8);
|
||||||
$episode['crew'] = $this->getCrew($episode['credits']['crew'] ?? [], 8);
|
$episode['crew'] = $this->getCrew($episode['credits']['crew'] ?? [], 8);
|
||||||
$episode['air_date'] = Helpers::formatReleaseDate($episode['air_date']);
|
$episode['air_date'] = self::formatReleaseDate($episode['air_date']);
|
||||||
$episode['vote_average'] = round($episode['vote_average']/2, 1);
|
$episode['vote_average'] = round($episode['vote_average'], 1);
|
||||||
$episode['label'] = 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT).'E'.str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
|
$episode['label'] = 'S'.str_pad($episode['season_number'], 2, '0', STR_PAD_LEFT).'E'.str_pad($episode['episode_number'], 2, '0', STR_PAD_LEFT);
|
||||||
|
// unset($episode['still_path']);
|
||||||
unset($episode['still_path']);
|
|
||||||
|
|
||||||
unset($episode['credits']);
|
unset($episode['credits']);
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
@section('app')
|
@section('app')
|
||||||
<section class="inner-hero bg_img dark--overlay lazy main-watch" data-id="{{ $show['id'] }}" data-type="show">
|
<section class="inner-hero bg_img dark--overlay lazy main-watch" data-id="{{ $show['id'] }}" data-type="show">
|
||||||
<figure>
|
<figure>
|
||||||
<img @if(isset($show['backdrop']) && $show['backdrop'] !== '') {{-- src="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}}" --}} data-srcset="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}} 360w, {{img_url('w1280', $show['backdrop_path'], true, 1280, 720 )}} 1280w" class="lazy" @endif width="100%" height="720" alt="{{ str($show['title'])->apa() }} ({{ $show['year'] }})" src="data:image/svg+xml,%3Csvg width='1280' height='720' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1280' height='720' x='0' y='0' fill='%231B1B3F' /%3E%3C/svg%3E" data-sizes="70vw, 100vw">
|
<img @if(isset($show['backdrop_path']) && $show['backdrop_path'] !== '') {{-- src="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}}" --}} data-srcset="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}} 360w, {{img_url('w1280', $show['backdrop_path'], true, 1280, 720 )}} 1280w" class="lazy" @endif width="100%" height="720" alt="{{ str($show['title'])->apa() }} ({{ $show['year'] }})" src="data:image/svg+xml,%3Csvg width='1280' height='720' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1280' height='720' x='0' y='0' fill='%231B1B3F' /%3E%3C/svg%3E" data-sizes="70vw, 100vw">
|
||||||
</figure>
|
</figure>
|
||||||
<div class="container position-relative">
|
<div class="container position-relative">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h1 class="text-center">{{ str($show['title'])->apa() }}</h1>
|
<h1 class="text-center">{{ $show['title'] }}</h1>
|
||||||
@if($show['tagline'])
|
@if($show['tagline'])
|
||||||
<p class="text-center fst-italic fs-5">"{{ $show['tagline'] }}"</p>
|
<p class="text-center fst-italic fs-5">"{{ $show['tagline'] }}"</p>
|
||||||
@endif
|
@endif
|
||||||
|
@ -44,10 +44,23 @@
|
||||||
<div class="movie-content">
|
<div class="movie-content">
|
||||||
<div class="movie-content-inner d-sm-flex justify-content-between align-items-center flex-wrap">
|
<div class="movie-content-inner d-sm-flex justify-content-between align-items-center flex-wrap">
|
||||||
<div class="movie-content-left">
|
<div class="movie-content-left">
|
||||||
<h2 class="title">Watch {{ str($show['title'])->apa() }}</h2>
|
<h2 class="title">Watch {{ str($show['title']) }} @unless($is_show_page)
|
||||||
|
<span class="ps-3"> - {{ str($episode['name'] ?? $season['name']) }}</span>
|
||||||
|
@endunless() </h2>
|
||||||
|
|
||||||
<span class="sub-title">Type : <span class="cat"><a href="{{route('shows',['page' => null])}}">TV Show</a></span>
|
<span class="sub-title">Type : <span class="cat">
|
||||||
Seasons: {{ count($show['seasons']) }}
|
@if($episode)
|
||||||
|
Episode
|
||||||
|
<span class="ps-2">Season: {{ $episode['season_number'] }}</span>
|
||||||
|
<span class="ps-2">Episode: {{ $episode['episode_number'] }}</span>
|
||||||
|
@elseif ($season)
|
||||||
|
Season
|
||||||
|
<span class="ps-2">Season: {{ $season['season_number'] }}</span>
|
||||||
|
@else
|
||||||
|
<a href="{{route('shows',['page' => null])}}">TV Show</a>
|
||||||
|
Seasons: {{ count($show['seasons']) }}
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="movie-content-right mt-sm-0 mt-3">
|
<div class="movie-content-right mt-sm-0 mt-3">
|
||||||
|
@ -337,9 +350,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row row-cols-2 row-cols-sm-4 row-cols-lg-6 row-cols-xl-8 g-4">
|
<div class="row row-cols-2 row-cols-sm-4 row-cols-lg-6 row-cols-xl-8 g-4">
|
||||||
@foreach ($airing as $item)
|
{{-- @foreach ($airing as $item)
|
||||||
@include('components.show_card')
|
@include('components.show_card')
|
||||||
@endforeach
|
@endforeach --}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,8 +34,13 @@
|
||||||
|
|
||||||
|
|
||||||
Route::get('/movie/{id}/{slug}', [MovieController::class, 'index'])->name('movie');
|
Route::get('/movie/{id}/{slug}', [MovieController::class, 'index'])->name('movie');
|
||||||
Route::get('/series/{id}/{slug}', [ShowController::class, 'index'])->name('show');
|
|
||||||
Route::get('/series/{id}/{slug}/season/{season}', [ShowController::class, 'season'])->name('show.season');
|
Route::group(['prefix' => '/series'], function(){
|
||||||
|
Route::get('/{id}/{slug}', [ShowController::class, 'index'])->name('show');
|
||||||
|
Route::get('/{id}/{slug}/season/{season}', [ShowController::class, 'season'])->name('show.season');
|
||||||
|
Route::get('/{id}/{slug}/season/{season}/episode/{episode}', [ShowController::class, 'episode'])->name('show.episode');
|
||||||
|
});
|
||||||
|
|
||||||
Route::get('/person/{person_id}/{slug}', [PeopleController::class, 'index'])->name('person');
|
Route::get('/person/{person_id}/{slug}', [PeopleController::class, 'index'])->name('person');
|
||||||
Route::get('/search', [HomeController::class, 'search'])->name('search');
|
Route::get('/search', [HomeController::class, 'search'])->name('search');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue