Пример #1
0
 public function doPost(JsonResponse $response, HttpPost $post)
 {
     $song_id = $post->get("song_id")->reject("")->get();
     $metadata = $post->get("metadata")->filter("is_array")->get();
     $result = count($metadata) == 0 ? array() : Songs::edit($song_id, $metadata);
     $response->write(["tracks" => $result]);
 }
Пример #2
0
 public function doPost(JsonResponse $response, LoggedIn $me, HttpFiles $files, $track_id)
 {
     $artwork_file = $files->getOrError("artwork_file");
     $temp_image = TempFileProvider::generate("", $artwork_file["name"]);
     move_uploaded_file($artwork_file["tmp_name"], $temp_image);
     $response->write(Songs::changeCover($track_id, $temp_image));
 }
Пример #3
0
 public function doGet(JsonResponse $response, $track_id, $artist, $album)
 {
     $scrobbler = new AudioScrobbler();
     $cover = $scrobbler->getAlbumCover($artist, $album);
     if ($cover->nonEmpty()) {
         $response->write(Songs::changeCover($track_id, $cover->get()));
     } else {
         throw new ControllerException("Artwork not found");
     }
 }
Пример #4
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);
     }
 }
Пример #5
0
 public function doPost(JsonResponse $response, $track_artist)
 {
     $deleted_songs = Songs::deleteByArtist($track_artist);
     $response->write($deleted_songs);
 }
Пример #6
0
 public function doPost(JsonResponse $response)
 {
     $response->write(Songs::create(), 201);
 }
Пример #7
0
 public function doPost(JsonResponse $response, $song_id)
 {
     Songs::delete($song_id);
 }