/** * */ public static function updateFile($params) { $path = $params['path']; require_once 'lib_scanner.php'; require_once 'lib_collection.php'; //fix a bug where there were multiply '/' in front of the path, it should only be one while ($path[0] == '/') { $path = substr($path, 1); } $path = '/' . $path; error_log("{$path} was updated"); OC_MEDIA_SCANNER::scanFile($path); }
break; case 'get_artists': OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search'])); break; case 'get_albums': OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'], $arguments['search'])); break; case 'get_songs': OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'], $arguments['album'], $arguments['search'])); break; case 'get_path_info': if (OC_Filesystem::file_exists($arguments['path'])) { $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); if ($songId == 0) { unset($_SESSION['collection']); $songId = OC_MEDIA_SCANNER::scanFile($arguments['path']); } if ($songId > 0) { $song = OC_MEDIA_COLLECTION::getSong($songId); $song['artist'] = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']); $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); OC_JSON::encodedPrint($song); } } break; case 'play': ob_end_clean(); $ftype = OC_Filesystem::getMimeType($arguments['path']); $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); OC_MEDIA_COLLECTION::registerPlay($songId); header('Content-Type:' . $ftype);