Example #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);
     }
 }
Example #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);
 }
Example #3
0
<?php

/**
 * Created by PhpStorm.
 * User: Roman
 * Date: 28.07.2015
 * Time: 9:30
 */
use app\core\cache\TempFileProvider;
use app\core\etc\Settings;
use app\core\injector\Injector;
use app\libs\WaveformGenerator;
Injector::run(function (Settings $settings) {
    WaveformGenerator::setCommand($settings->get("tools", "ffmpeg_cmd"));
    TempFileProvider::setTempPath($settings->get("fs", "temp"));
});