Handling the case when there is no video yet, locally or online.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
@endif
|
||||
</div>
|
||||
<div class="col">
|
||||
@if($videoUrl)
|
||||
<div class="d-flex justify-content-center">
|
||||
<video class="mx-auto" width="500" controls>
|
||||
<source src="{{ $videoUrl }}" type="video/mp4"/>
|
||||
</video>
|
||||
</div>
|
||||
@if($chapter->is_video_file)
|
||||
@else
|
||||
no video
|
||||
@endif
|
||||
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user