public function url_to_song($params) { if (!$this->checkAuth($params)) { $this->error(400, 'Invalid Login'); } $url = $params['url']; $songId = substr($url, strrpos($url, 'song=') + 5); if ($song = $this->collection->getSong($songId)) { $this->printSongs(array($song)); } }
case 'get_albums': \OCP\JSON::encodedPrint($collection->getAlbums($arguments['artist'], $arguments['search'])); break; case 'get_songs': \OCP\JSON::encodedPrint($collection->getSongs($arguments['artist'], $arguments['album'], $arguments['search'])); break; case 'get_path_info': if (\OC\Files\Filesystem::file_exists($arguments['path'])) { $songId = $collection->getSongByPath($arguments['path']); if ($songId == 0) { unset($_SESSION['collection']); $scanner = new Scanner($collection); $songId = $scanner->scanFile($arguments['path']); } if ($songId > 0) { $song = $collection->getSong($songId); $song['artist'] = $collection->getArtistName($song['song_artist']); $song['album'] = $collection->getAlbumName($song['song_album']); \OCP\JSON::encodedPrint($song); } } break; case 'play': $ftype = \OC\Files\Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = $collection->getSongByPath($arguments['path']); $collection->registerPlay($songId); header('Content-Type:' . $ftype);