public function dispatch(Request $request, Response $response, $args) { // Get Cuisine Types from json $cuisineTypes = Utils::getCuisineTypes(); $dressCodes = Utils::getDressCodes(); $reservations = Utils::getReservations(); $alcoholTypes = Utils::getAlcoholTypes(); $musicTypes = Utils::getMusicTypes(); $this->logger->info("Company Environment page action dispatched"); // Get messages $messages = $this->flash->getMessages(); $body = $this->view->fetch('company/environment/environment.twig', ['flash' => $messages, 'company' => $this->currentCompany, 'cuisineTypes' => $cuisineTypes->data, 'dressCodes' => $dressCodes->data, 'reservations' => $reservations->data, 'alcoholTypes' => $alcoholTypes->data, 'musicTypes' => $musicTypes->data]); return $response->write($body); }
/** * Download Episodes * @param $diff * @param $counter * @param $new_episodes */ public function downloadEpisodes(&$diff, &$counter, $new_episodes) { $this->system->createFolderIfNotExists(SERIES_FOLDER); Utils::box('Downloading Series'); foreach ($diff['series'] as $serie => $episodes) { $this->system->createSerieFolderIfNotExists($serie); foreach ($episodes as $episode) { if ($this->client->downloadSerieEpisode($serie, $episode) === false) { $counter['failed_episode'] = $counter['failed_episode'] + 1; } Utils::write(sprintf("Current: %d of %d total. Left: %d", $counter['series']++, $new_episodes, $new_episodes - $counter['series'] + 1)); } } }
/** * run write commands */ public function writeSkipFiles() { Utils::box('Creating skip files'); $this->writeSkipSeries(); Utils::write('Skip files for series created'); $this->writeSkipLessons(); Utils::write('Skip files for lesson created'); Utils::box('Finished'); }
/** * Helper to download the video. * * @param $name * @param $path * @param $saveTo */ private function downloadLessonFromPath($path, $saveTo) { $response = $this->client->get($path, ['cookies' => $this->cookie]); $downloadUrl = Parser::getDownloadLink($response->getBody()->getContents()); $viemoUrl = $this->getRedirectUrl($downloadUrl); $finalUrl = $this->getRedirectUrl($viemoUrl); $this->bench->start(); $this->client->get($finalUrl, ['save_to' => $saveTo]); $this->bench->end(); Utils::write(sprintf("Elapsed time: %s, Memory: %s", $this->bench->getTime(), $this->bench->getMemoryUsage())); }
/** * Helper to download the video. * * @param $html * @param $saveTo * @return bool */ private function downloadLessonFromPath($html, $saveTo) { try { $downloadUrl = Parser::getDownloadLink($html); } catch (NoDownloadLinkException $e) { Utils::write(sprintf("Can't download this lesson! :( No download button")); return false; } $viemoUrl = $this->getRedirectUrl($downloadUrl); $finalUrl = $this->getRedirectUrl($viemoUrl); $this->bench->start(); $req = $this->client->createRequest('GET', $finalUrl, ['save_to' => $saveTo, 'verify' => false]); if (php_sapi_name() == "cli") { //on cli show progress $req->getEmitter()->on('progress', function (ProgressEvent $e) { printf("> Total: %d%% Downloaded: %s of %s \r", Utils::getPercentage($e->downloaded, $e->downloadSize), Utils::formatBytes($e->downloaded), Utils::formatBytes($e->downloadSize)); }); } $this->client->send($req); $this->bench->end(); Utils::write(sprintf("Elapsed time: %s, Memory: %s", $this->bench->getTime(), $this->bench->getMemoryUsage())); return true; }