Added total time of a course, marking chapters and courses to sync offline.

This commit is contained in:
Krzysztof Płaczek
2022-09-15 14:35:02 +02:00
parent fc23506f92
commit b158ec6b5d
9 changed files with 43 additions and 14 deletions

View File

@@ -31,6 +31,7 @@ class HtmlParser
$course->course_id = $courseItem->attr('data-id');
$course->numberofchapters = $courseItem->attr('data-chapter-count');
$course->timeswatched = $courseItem->attr('data-times-watched');
$course->course_duration = $courseItem->first('.font-blue.fal.fa-clock.pr-1')?->parent()?->text();
$course->published_at = $courseItem->attr('data-date') > 0 ? Carbon::createFromTimestamp(
$courseItem->attr('data-date')
) : null;
@@ -55,10 +56,10 @@ class HtmlParser
$chapter->duration = $chapterItem->first('.length-styling')?->text();
$chapter->order = $chapterId;
$chapter->course_id = $courseId;
$chapter->link = config('symfonycast.base_url') . $chapterItem->first('a')->attr('href');
$chapter->video_link = config('symfonycast.base_url') . $chapterItem->first('a')->attr(
'href'
) . '/download/video';
if ($link = trim($chapterItem->first('a')->attr('href'), '#')) {
$chapter->link = config('symfonycast.base_url') . $link;
$chapter->video_link = config('symfonycast.base_url') . $link . '/download/video';
}
$chapter->title = preg_replace('/\v(?:[\v\h]+)/', '', $chapterItem->first('.col')->text());
$chapter->video_size = 0;
$chapters->add($chapter);