function findMusic($path = '') { $music = array(); $dh = OC_Filesystem::opendir($path); if ($dh) { while ($filename = readdir($dh)) { if ($filename[0] != '.') { $file = $path . '/' . $filename; if (OC_Filesystem::is_dir($file)) { $music = array_merge($music, findMusic($file)); } else { if (OC_MEDIA_SCANNER::isMusic($filename)) { $music[] = $file; } } } } } return $music; }
break; case 'sync': folderToPlaylist(); break; } } if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) { switch ($_SERVER['REQUEST_METHOD']) { case 'POST': if (isset($_REQUEST['playlist'])) { $playlist = createPlaylist($_REQUEST); echo json_encode($playlist); } else { $settings = new Settings(); $musicPath = $settings->getSettings('Files', 'music'); findMusic($musicPath); http_response_code(202); } break; case 'GET': echo json_encode(get($_REQUEST)); break; case 'PUT': update($_REQUEST); break; case 'DELETE': delete($_REQUEST); break; } } function delete($arr)