Пример #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
 /**
  * @param $track_artist
  * @return MLArray
  */
 public static function deleteByArtist($track_artist)
 {
     $songs = SongDao::getList([TSongs::T_ARTIST => $track_artist, TSongs::USER_ID => self::$me->getId()]);
     $to_remove = $songs->map(Mapper::key(TSongs::ID));
     if (count($to_remove) == 0) {
         return array();
     }
     return (new DeleteQuery(TSongs::_NAME))->where(TSongs::ID, $to_remove->mkArray())->returning("*")->fetchAll();
 }
Пример #3
0
 /**
  * @param $play_count
  * @return mixed
  */
 public function updateAndGetPlayCount($play_count)
 {
     if ($play_count > $this->track_data[TSongs::T_PLAYED]) {
         SongDao::updateSongUsingId($this->track_id, ["times_played" => $play_count]);
         return $play_count;
     }
     return $this->track_data[TSongs::T_PLAYED];
 }
Пример #4
0
 public function doPost(JsonResponse $response, $id)
 {
     $song = SongDao::getSongUsingId($id);
     $scrobbler = new AudioScrobbler();
     $scrobbler->nowPlaying($song[TSongs::T_TITLE], $song[TSongs::T_ARTIST], $song[TSongs::T_ALBUM]);
 }