Added command to update all courses and chapters, downloading videos and checking video size is split into two queues, chapters can be mark to sync individually, updated readme, check if subscription is active, playback rate controll,
This commit is contained in:
@@ -5,8 +5,10 @@ namespace App\Http\SymfonyCastDl;
|
||||
use App\Jobs\GetVideoFileSize;
|
||||
use App\Models\Chapter;
|
||||
use App\Models\Course;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\TransferStats;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Collection;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
|
||||
class SymfonyCastDlService
|
||||
@@ -33,26 +35,34 @@ class SymfonyCastDlService
|
||||
]);
|
||||
}
|
||||
|
||||
public function getInfo(): void
|
||||
/**
|
||||
* @return Collection
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function updateCourses(): Collection
|
||||
{
|
||||
$coursePage = $this->client->get('courses/filtering');
|
||||
$courses = $this->htmlParser->getCourses($coursePage);
|
||||
$courses->each->save();
|
||||
/** @var Course $course */
|
||||
foreach ($courses as $course) {
|
||||
$singleCoursePage = $this->client->get('/screencast/' . $course->link);
|
||||
$chapters = $this->htmlParser->getCourseDetails($singleCoursePage, $course->id);
|
||||
$chapters->each->save();
|
||||
$chapters->each(fn($chapter) => GetVideoFileSize::dispatch($chapter->id));
|
||||
}
|
||||
return $courses->each->save();
|
||||
}
|
||||
|
||||
public function updateCourse(Course $course): void
|
||||
/**
|
||||
* @param Course $course
|
||||
* @return Collection
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function updateChapters(Course $course): Collection
|
||||
{
|
||||
$singleCoursePage = $this->client->get('/screencast/' . $course->link);
|
||||
$chapters = $this->htmlParser->getCourseDetails($singleCoursePage, $course->id);
|
||||
$chapters->each->save();
|
||||
$chapters->each(fn($chapter) => GetVideoFileSize::dispatch($chapter->id));
|
||||
return $chapters;
|
||||
}
|
||||
|
||||
public function isSubscriptionActive(): bool
|
||||
{
|
||||
return $this->htmlParser->isSubscriptionActive($this->client->get('/profile/show'));
|
||||
}
|
||||
|
||||
public function getChapterInfo(Chapter $chapter): ?string
|
||||
@@ -89,5 +99,7 @@ class SymfonyCastDlService
|
||||
['sink' => $chapter->video_path],
|
||||
);
|
||||
}
|
||||
$chapter->video_size = filesize($chapter->video_path);
|
||||
$chapter->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user