コード例 #1
0
 /**
  * All the logic
  *
  * @param $options
  */
 public function start($options)
 {
     try {
         $counter = ['series' => 1, 'lessons' => 1];
         Utils::box('Starting Collecting the data');
         $this->bench->start();
         $localLessons = $this->system->getAllLessons();
         $allLessonsOnline = $this->client->getAllLessons();
         $this->bench->end();
         //Magic to get what to download
         $diff = Utils::resolveFaultyLessons($allLessonsOnline, $localLessons);
         $new_lessons = Utils::countLessons($diff);
         $new_episodes = Utils::countEpisodes($diff);
         Utils::write(sprintf("%d new lessons and %d episodes. %s elapsed with %s of memory usage.", $new_lessons, $new_episodes, $this->bench->getTime(), $this->bench->getMemoryUsage()));
         Utils::box('Authenticating');
         $this->doAuth($options);
         //Download Lessons
         if ($new_lessons > 0) {
             $this->downloadLessons($diff, $counter, $new_lessons);
         }
         //Donwload Episodes
         if ($new_episodes > 0) {
             $this->downloadEpisodes($diff, $counter, $new_episodes);
         }
         Utils::writeln(sprintf("Finished! Downloaded %d new lessons and %d new episodes.", $new_lessons, $new_episodes));
     } catch (LoginException $e) {
         Utils::write("Your login details are wrong!");
     } catch (SubscriptionNotActiveException $e) {
         Utils::write('Your subscription is not active!');
     }
 }
コード例 #2
0
 /**
  * Downloads the lesson.
  *
  * @param $lesson
  */
 public function downloadLesson($lesson)
 {
     $path = LARACASTS_LESSONS_PATH . '/' . $lesson;
     $number = sprintf("%04d", ++Downloader::$currentLessonNumber);
     $saveTo = BASE_FOLDER . '/' . LESSONS_FOLDER . '/' . $number . '-' . $lesson . '.mp4';
     Utils::writeln(sprintf("Download started: %s . . . . Saving on " . LESSONS_FOLDER . ' folder.', $lesson));
     $this->downloadLessonFromPath($path, $saveTo);
 }
コード例 #3
0
 /**
  * Downloads the lesson.
  *
  * @param $lesson
  * @return bool
  */
 public function downloadLesson($lesson)
 {
     $path = LARACASTS_LESSONS_PATH . '/' . $lesson;
     $number = sprintf("%04d", Downloader::$totalLocalLessons + Downloader::$currentLessonNumber--);
     $saveTo = BASE_FOLDER . '/' . LESSONS_FOLDER . '/' . $number . '-' . $lesson . '.mp4';
     Utils::writeln(sprintf("Download started: %s . . . . Saving on " . LESSONS_FOLDER . ' folder.', $lesson));
     $html = $this->getPage($path);
     return $this->downloadLessonFromPath($html, $saveTo);
 }