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 Inertia\Inertia;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Supports\Traits\Helpers;
|
||||
use App\Supports\Helpers;
|
||||
use App\Http\Requests\MoreMoviesRequest;
|
||||
use App\Http\Resources\MoreTitles;
|
||||
|
||||
|
@ -64,7 +64,6 @@ public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug =
|
|||
$id = self::decodeId($id);
|
||||
$show = $tmdb->getShow($id);
|
||||
|
||||
$data = $this->formatTmdbShow($show);
|
||||
if (isset($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 = $this->formatTmdbSeason($season, $show);
|
||||
}
|
||||
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
|
||||
// dd($data);
|
||||
// $data['meta']['title'] = 'Watch ' . $movie['title'];
|
||||
return $data;
|
||||
// $airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
|
||||
return $show;
|
||||
};
|
||||
$results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call);
|
||||
// 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 = [];
|
||||
$season_number = $season;
|
||||
$episode_number = $episode;
|
||||
$call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){
|
||||
$id = self::decodeId($id);
|
||||
$show = $tmdb->getShow($id);
|
||||
$data = $this->formatTmdbShow($show);
|
||||
$season = $tmdb->getSeason($show['id'], $season_number);
|
||||
$season = $this->formatTmdbSeason($season);
|
||||
$episode = $tmdb->getEpisode($show['id'], $season_number, $episode_number);
|
||||
$data = $tmdb->getShow($id);
|
||||
$season = $tmdb->getSeason($data['id'], $season_number);
|
||||
$season = $this->formatTmdbSeason($season, $data);
|
||||
$episode = $tmdb->getEpisode($data['id'], $season_number, $episode_number);
|
||||
$episode = $this->formatTmdbEpisode($episode);
|
||||
|
||||
// $episode
|
||||
// dd($data);
|
||||
// $data['meta']['title'] = 'Watch ' . $movie['title'];
|
||||
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);
|
||||
$meta['schema'] = SchemaBuilder::getShowEpisodeSchema($results, $season, $episode);
|
||||
$data = $results;
|
||||
$top = $this->getTopContent($tmdb, $api);
|
||||
// dd($data);
|
||||
// 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['schema'] = SchemaBuilder::getShowEpisodeSchema($show, $season, $episode);
|
||||
|
||||
// load episode background path if available
|
||||
$show['backdrop_path'] = $episode['still_path'] ?? $show['backdrop_path'];
|
||||
|
||||
$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['image'] = $episode['backdrop'];
|
||||
$meta['keywords'] = config('site.shows.detail_episode.keywords');
|
||||
|
||||
|
||||
// dd($season);
|
||||
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'));
|
||||
|
||||
$is_show_page = false;
|
||||
return view('show', compact('show', 'season', 'episode', 'meta', 'is_show_page'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ public static function getShowSeasonSchema($show, $season): array
|
|||
return Schema::person()->name($actor['name'])->image($actor['image']);
|
||||
})->values()->all();
|
||||
$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']);
|
||||
})->values()->all();
|
||||
$movieSchema->producer($directors);
|
||||
|
|
|
@ -19,14 +19,11 @@ protected function getPageLabel(?string $label)
|
|||
switch ($label) {
|
||||
case 'pagination.previous':
|
||||
return 'Previous';
|
||||
break;
|
||||
case 'pagination.next':
|
||||
return 'Next';
|
||||
break;
|
||||
|
||||
default:
|
||||
return $label;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -130,10 +127,10 @@ public function formatTmdbSeason($data, $showData):array
|
|||
$show['overview'] = $data['overview'] !== '' ? $data['overview'] : $showData['overview'];
|
||||
$show['cast'] = $this->getCast($show['credits']['cast'] ?? $showData['credits']['cast'] ?? [], 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['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['backdrop'] = $this->getImageUrl($episode['still_path'], 'w1280', 1280, 720);
|
||||
unset($episode['still_path']);
|
||||
|
@ -154,11 +151,10 @@ public function formatTmdbEpisode($data):array
|
|||
|
||||
$episode['cast'] = $this->getCast($episode['credits']['cast'] ?? [], 8);
|
||||
$episode['crew'] = $this->getCrew($episode['credits']['crew'] ?? [], 8);
|
||||
$episode['air_date'] = Helpers::formatReleaseDate($episode['air_date']);
|
||||
$episode['vote_average'] = round($episode['vote_average']/2, 1);
|
||||
$episode['air_date'] = self::formatReleaseDate($episode['air_date']);
|
||||
$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);
|
||||
|
||||
unset($episode['still_path']);
|
||||
// unset($episode['still_path']);
|
||||
|
||||
unset($episode['credits']);
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
@section('app')
|
||||
<section class="inner-hero bg_img dark--overlay lazy main-watch" data-id="{{ $show['id'] }}" data-type="show">
|
||||
<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>
|
||||
<div class="container position-relative">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="text-center">{{ str($show['title'])->apa() }}</h1>
|
||||
<h1 class="text-center">{{ $show['title'] }}</h1>
|
||||
@if($show['tagline'])
|
||||
<p class="text-center fst-italic fs-5">"{{ $show['tagline'] }}"</p>
|
||||
@endif
|
||||
|
@ -44,10 +44,23 @@
|
|||
<div class="movie-content">
|
||||
<div class="movie-content-inner d-sm-flex justify-content-between align-items-center flex-wrap">
|
||||
<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">
|
||||
@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>
|
||||
</div>
|
||||
<div class="movie-content-right mt-sm-0 mt-3">
|
||||
|
@ -337,9 +350,9 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<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')
|
||||
@endforeach
|
||||
@endforeach --}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -34,8 +34,13 @@
|
|||
|
||||
|
||||
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('/search', [HomeController::class, 'search'])->name('search');
|
||||
|
||||
|
|
Loading…
Reference in a new issue