maintanance and downloading files.

This commit is contained in:
Krzysztof Płaczek
2022-11-16 07:18:21 +01:00
parent 086e4b56b5
commit 21f61b0911
10 changed files with 88 additions and 36 deletions

View File

@@ -26,7 +26,7 @@ class HtmlParser
$course = Course::firstOrNew(['course_id' => $courseId]);
$course->name = $courseItem->first('h3')->text();
$course->thumbnail = $courseItem->first('img.course-list-item-img')->attr('src');
$course->link = $courseItem->first('a')->attr('href');
$course->link = last(explode('/', $courseItem->first('a')->attr('href')));
$course->status = $courseItem->attr('data-status');
$course->course_id = $courseItem->attr('data-id');
$course->numberofchapters = $courseItem->attr('data-chapter-count');
@@ -49,15 +49,12 @@ class HtmlParser
if ($chapterItem->first('.col')) {
$chapterId++;
// if(!$chapterItem->first('.length-styling')){
// dd($chapterItem->html());
// }
$chapter = Chapter::firstOrNew(['course_id' => $courseId, 'order' => $chapterId]);
$chapter->duration = $chapterItem->first('.length-styling')?->text();
$chapter->order = $chapterId;
$chapter->course_id = $courseId;
if ($link = trim($chapterItem->first('a')->attr('href'), '#')) {
$chapter->link = config('symfonycast.base_url') . $link;
$chapter->link = last(explode('/', $link));;
$chapter->video_link = config('symfonycast.base_url') . $link . '/download/video';
}
$chapter->title = preg_replace('/\v(?:[\v\h]+)/', '', $chapterItem->first('.col')->text());