Пример #1
0
 public function doGet()
 {
     Songs::wipeOldPreviews();
     FileServer::removeUnused();
     FileServer::removeDead();
     $limit = 30;
     while ($limit-- > 0) {
         set_time_limit(30);
         (new SelectQuery(TSongs::_NAME))->select(TSongs::FILE_NAME, TSongs::FILE_ID, TSongs::ID)->where(TSongs::PEAKS_ID . " IS NULL")->where(TSongs::FILE_ID . " IS NOT NULL")->limit(1)->eachRow(function ($row) {
             Logger::printf("Creating peaks for file: %s", $row[TSongs::FILE_NAME]);
             $peaks = WaveformGenerator::generate(FileServer::getFileUsingId($row[TSongs::FILE_ID]));
             $file_id = FileServer::registerByContent(json_encode($peaks), "application/json");
             SongDao::updateSongUsingId($row[TSongs::ID], [TSongs::PEAKS_ID => $file_id]);
         });
         sleep(1);
     }
 }
Пример #2
0
 /**
  * @return mixed
  * @throws ControllerException
  */
 public function getPeaks()
 {
     if (!$this->hasPeaks()) {
         $new_peaks = WaveformGenerator::generate($this->getFilePath());
         $file_id = FileServer::registerByContent(json_encode($new_peaks), "application/json");
         SongDao::updateSongUsingId($this->track_id, [TSongs::PEAKS_ID => $file_id]);
     } else {
         $file_id = $this->track_data[TSongs::PEAKS_ID];
     }
     http_response_code(HttpStatusCodes::HTTP_MOVED_PERMANENTLY);
     header("Location: /file/" . $file_id);
 }