diff --git a/app/Http/SymfonyCastDl/HtmlParser.php b/app/Http/SymfonyCastDl/HtmlParser.php index 0a2d808..b3c5f7c 100644 --- a/app/Http/SymfonyCastDl/HtmlParser.php +++ b/app/Http/SymfonyCastDl/HtmlParser.php @@ -65,10 +65,10 @@ class HtmlParser return $chapters; } - public function getVideoSource(Response $respose): string + public function getVideoSource(Response $respose): ?string { $document = new Document($respose->getBody()->getContents()); - return $document->first('video source')->getAttribute('src'); + return $document->first('video source')?->getAttribute('src'); } } diff --git a/app/Http/SymfonyCastDl/SymfonyCastDlService.php b/app/Http/SymfonyCastDl/SymfonyCastDlService.php index c84f066..c8c0a5a 100644 --- a/app/Http/SymfonyCastDl/SymfonyCastDlService.php +++ b/app/Http/SymfonyCastDl/SymfonyCastDlService.php @@ -55,7 +55,7 @@ class SymfonyCastDlService $chapters->each(fn($chapter) => GetVideoFileSize::dispatch($chapter->id)); } - public function getChapterInfo(Chapter $chapter): string + public function getChapterInfo(Chapter $chapter): ?string { $course = $chapter->course; $chapterPage = $this->client->get('/screencast/' . $course->link . DIRECTORY_SEPARATOR . $chapter->link); @@ -64,7 +64,7 @@ class SymfonyCastDlService public function videoSize(Chapter $chapter): Chapter { - if (!$chapter->video_size) { + if (!$chapter->video_size && $chapter->video_link) { $response = $this->client->head($chapter->video_link); if ($response->hasHeader('Content-Length')) { $chapter->video_size = (int)$response->getHeader('Content-Length')[0]; diff --git a/resources/views/chapter/index.blade.php b/resources/views/chapter/index.blade.php index ad80019..c54e240 100644 --- a/resources/views/chapter/index.blade.php +++ b/resources/views/chapter/index.blade.php @@ -17,12 +17,14 @@ @endif