diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 7cdae43440fe0..acb0cb9060cd4 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -4752,18 +4752,23 @@ void CApplication::StopMusicScan() } void CApplication::StartVideoCleanup(bool userInitiated /* = true */, - const std::string& content /* = "" */) + const std::string& content /* = "" */, + const std::string& strDirectory /* = "" */) { if (userInitiated && CVideoLibraryQueue::GetInstance().IsRunning()) return; std::set paths; - if (!content.empty()) + if (!content.empty() || !strDirectory.empty()) { CVideoDatabase db; std::set contentPaths; - if (db.Open() && db.GetPaths(contentPaths)) + if (db.Open()) { + if (!strDirectory.empty()) + contentPaths.insert(strDirectory); + else + db.GetPaths(contentPaths); for (const std::string& path : contentPaths) { if (db.GetContentForPath(path) == content) diff --git a/xbmc/Application.h b/xbmc/Application.h index 2a458e2aee0de..5babd5a8fd146 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -259,8 +259,9 @@ friend class CAppInboundProtocol; \brief Starts a video library cleanup. \param userInitiated Whether the action was initiated by the user (either via GUI or any other method) or not. It is meant to hide or show dialogs. \param content Content type to clean, blank for everything + \param strDirectory The path to clean or "" (empty string) for a global clean. */ - void StartVideoCleanup(bool userInitiated = true, const std::string& content = ""); + void StartVideoCleanup(bool userInitiated = true, const std::string& content = "", const std::string& strDirectory = ""); /*! \brief Starts a video library update. diff --git a/xbmc/interfaces/builtins/LibraryBuiltins.cpp b/xbmc/interfaces/builtins/LibraryBuiltins.cpp index 5a828c15d20f3..407757a77d0fc 100644 --- a/xbmc/interfaces/builtins/LibraryBuiltins.cpp +++ b/xbmc/interfaces/builtins/LibraryBuiltins.cpp @@ -46,7 +46,7 @@ static int CleanLibrary(const std::vector& params) if (!g_application.IsVideoScanning()) { const std::string content = (params.empty() || params[0] == "video") ? "" : params[0]; - g_application.StartVideoCleanup(userInitiated, content); + g_application.StartVideoCleanup(userInitiated, content, params.size() > 2 ? params[2] : ""); } else CLog::Log(LOGERROR, "CleanLibrary is not possible while scanning or cleaning"); diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp index fa3de223f85a8..83b05762b667f 100644 --- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp +++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp @@ -901,11 +901,16 @@ JSONRPC_STATUS CVideoLibrary::Export(const std::string &method, ITransportLayer JSONRPC_STATUS CVideoLibrary::Clean(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { + std::string directory = parameterObject["directory"].asString(); std::string cmd; if (parameterObject["content"].empty()) - cmd = StringUtils::Format("cleanlibrary(video, {0})", parameterObject["showdialogs"].asBoolean() ? "true" : "false"); + cmd = StringUtils::Format("cleanlibrary(video, {0}, {1})", + parameterObject["showdialogs"].asBoolean() ? "true" : "false", + StringUtils::Paramify(directory).c_str()); else - cmd = StringUtils::Format("cleanlibrary({0}, {1})", parameterObject["content"].asString(), parameterObject["showdialogs"].asBoolean() ? "true" : "false"); + cmd = StringUtils::Format("cleanlibrary({0}, {1}, {2})", parameterObject["content"].asString(), + parameterObject["showdialogs"].asBoolean() ? "true" : "false", + StringUtils::Paramify(directory).c_str()); CApplicationMessenger::GetInstance().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index 079eb7efeac24..f809ee114393a 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -1821,7 +1821,8 @@ "permission": "RemoveData", "params": [ { "name": "showdialogs", "type": "boolean", "default": true, "description": "Whether or not to show the progress bar or any other GUI dialog" }, - { "name": "content", "type": "string", "default": "video", "enum": [ "video", "movies", "tvshows", "musicvideos" ], "description": "Content type to clean for" } + { "name": "content", "type": "string", "default": "video", "enum": [ "video", "movies", "tvshows", "musicvideos" ], "description": "Content type to clean for" }, + { "name": "directory", "type": "string", "default": "", "description": "Path to the directory to clean up; performs a global cleanup if not specified" } ], "returns": "string" }, diff --git a/xbmc/interfaces/json-rpc/schema/version.txt b/xbmc/interfaces/json-rpc/schema/version.txt index 19b4e985c7a38..f0bec166214c3 100644 --- a/xbmc/interfaces/json-rpc/schema/version.txt +++ b/xbmc/interfaces/json-rpc/schema/version.txt @@ -1 +1 @@ -JSONRPC_VERSION 11.14.0 +JSONRPC_VERSION 11.15.0