Displaying videos directly from link from symfony cast website without downloading.

This commit is contained in:
Krzysztof Płaczek
2023-03-31 11:25:32 +02:00
parent dce3cdd929
commit 32ead90121
4 changed files with 21 additions and 7 deletions

View File

@@ -49,7 +49,6 @@ class HtmlParser
foreach ($document->find('ul.chapter-list li') as $chapterItem) {
if ($chapterItem->first('.col')) {
$chapterId++;
$chapter = Chapter::firstOrNew(['course_id' => $courseId, 'order' => $chapterId]);
$chapter->duration = $chapterItem->first('.length-styling')?->text();
$chapter->order = $chapterId;
@@ -63,8 +62,13 @@ class HtmlParser
$chapters->add($chapter);
}
}
return $chapters;
}
public function getVideoSource(Response $respose): string
{
$document = new Document($respose->getBody()->getContents());
return $document->first('video source')->getAttribute('src');
}
}

View File

@@ -7,6 +7,7 @@ use App\Models\Chapter;
use App\Models\Course;
use GuzzleHttp\TransferStats;
use GuzzleHttp\Client;
use JetBrains\PhpStorm\NoReturn;
class SymfonyCastDlService
{
@@ -46,6 +47,13 @@ class SymfonyCastDlService
}
}
public function getChapterInfo(Chapter $chapter): string
{
$course = $chapter->course;
$chapterPage = $this->client->get('/screencast/' . $course->link . DIRECTORY_SEPARATOR . $chapter->link);
return $this->htmlParser->getVideoSource($chapterPage);
}
public function videoSize(Chapter $chapter): Chapter
{
if (!$chapter->video_size) {