diff options
author | Sascha Montellese <sascha.montellese@gmail.com> | 2013-11-04 13:37:10 -0800 |
---|---|---|
committer | Sascha Montellese <sascha.montellese@gmail.com> | 2013-11-04 13:37:10 -0800 |
commit | be9836739b49f090fd91abda2e6e7282cfcb7cac (patch) | |
tree | 16730eb36d6a243dd93cd8a723237478d7e54e93 | |
parent | 4cb1e8451f697d92be2b5a0fd0002b407a8bc4af (diff) | |
parent | 16a400e73e4ecaeb55c4758da8c25fda1ab7840a (diff) |
Merge pull request #3556 from Montellese/jsonrpc_setmoviesetdetails
jsonrpc: add VideoLibrary.SetMovieSetDetails
-rw-r--r-- | addons/xbmc.json/addon.xml | 2 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/JSONServiceDescription.cpp | 1 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/ServiceDescription.h | 14 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/VideoLibrary.cpp | 33 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/VideoLibrary.h | 1 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/methods.json | 12 | ||||
-rw-r--r-- | xbmc/video/VideoDatabase.cpp | 35 | ||||
-rw-r--r-- | xbmc/video/VideoDatabase.h | 1 |
8 files changed, 97 insertions, 2 deletions
diff --git a/addons/xbmc.json/addon.xml b/addons/xbmc.json/addon.xml index acf321482b..6886782f8e 100644 --- a/addons/xbmc.json/addon.xml +++ b/addons/xbmc.json/addon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<addon id="xbmc.json" version="6.11.0" provider-name="Team XBMC"> +<addon id="xbmc.json" version="6.12.0" provider-name="Team XBMC"> <backwards-compatibility abi="6.0.0"/> <requires> <import addon="xbmc.core" version="0.1.0"/> diff --git a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp index 8ffdca1c83..247cd29e03 100644 --- a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp +++ b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp @@ -134,6 +134,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = { { "VideoLibrary.GetRecentlyAddedEpisodes", CVideoLibrary::GetRecentlyAddedEpisodes }, { "VideoLibrary.GetRecentlyAddedMusicVideos", CVideoLibrary::GetRecentlyAddedMusicVideos }, { "VideoLibrary.SetMovieDetails", CVideoLibrary::SetMovieDetails }, + { "VideoLibrary.SetMovieSetDetails", CVideoLibrary::SetMovieSetDetails }, { "VideoLibrary.SetTVShowDetails", CVideoLibrary::SetTVShowDetails }, { "VideoLibrary.SetSeasonDetails", CVideoLibrary::SetSeasonDetails }, { "VideoLibrary.SetEpisodeDetails", CVideoLibrary::SetEpisodeDetails }, diff --git a/xbmc/interfaces/json-rpc/ServiceDescription.h b/xbmc/interfaces/json-rpc/ServiceDescription.h index d2fe03613b..1c58d9de16 100644 --- a/xbmc/interfaces/json-rpc/ServiceDescription.h +++ b/xbmc/interfaces/json-rpc/ServiceDescription.h @@ -22,7 +22,7 @@ namespace JSONRPC { const char* const JSONRPC_SERVICE_ID = "http://xbmc.org/jsonrpc/ServiceDescription.json"; - const char* const JSONRPC_SERVICE_VERSION = "6.11.0"; + const char* const JSONRPC_SERVICE_VERSION = "6.12.0"; const char* const JSONRPC_SERVICE_DESCRIPTION = "JSON-RPC API of XBMC"; const char* const JSONRPC_SERVICE_TYPES[] = { @@ -2699,6 +2699,18 @@ namespace JSONRPC "]," "\"returns\": \"string\"" "}", + "\"VideoLibrary.SetMovieSetDetails\": {" + "\"type\": \"method\"," + "\"description\": \"Update the given movie set with the given details\"," + "\"transport\": \"Response\"," + "\"permission\": \"UpdateData\"," + "\"params\": [" + "{ \"name\": \"setid\", \"$ref\": \"Library.Id\", \"required\": true }," + "{ \"name\": \"title\", \"$ref\": \"Optional.String\" }," + "{ \"name\": \"art\", \"type\": [ \"null\", { \"$ref\": \"Media.Artwork.Set\", \"required\": true } ], \"default\": null }" + "]," + "\"returns\": \"string\"" + "}", "\"VideoLibrary.SetTVShowDetails\": {" "\"type\": \"method\"," "\"description\": \"Update the given tvshow with the given details\"," diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp index 89b5acfd41..cdd84b6dd2 100644 --- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp +++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp @@ -518,6 +518,39 @@ JSONRPC_STATUS CVideoLibrary::SetMovieDetails(const CStdString &method, ITranspo return ACK; } +JSONRPC_STATUS CVideoLibrary::SetMovieSetDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) +{ + int id = (int)parameterObject["setid"].asInteger(); + + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return InternalError; + + CVideoInfoTag infos; + videodatabase.GetSetInfo(id, infos); + if (infos.m_iDbId <= 0) + { + videodatabase.Close(); + return InvalidParams; + } + + // get artwork + std::map<std::string, std::string> artwork; + videodatabase.GetArtForItem(infos.m_iDbId, infos.m_type, artwork); + + std::set<std::string> removedArtwork; + UpdateVideoTag(parameterObject, infos, artwork, removedArtwork); + + if (videodatabase.SetDetailsForMovieSet(infos, artwork, id) <= 0) + return InternalError; + + if (!videodatabase.RemoveArtForItem(infos.m_iDbId, "set", removedArtwork)) + return InternalError; + + CJSONRPCUtils::NotifyItemUpdated(); + return ACK; +} + JSONRPC_STATUS CVideoLibrary::SetTVShowDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { int id = (int)parameterObject["tvshowid"].asInteger(); diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.h b/xbmc/interfaces/json-rpc/VideoLibrary.h index 1ba996bc77..919f0f05e5 100644 --- a/xbmc/interfaces/json-rpc/VideoLibrary.h +++ b/xbmc/interfaces/json-rpc/VideoLibrary.h @@ -53,6 +53,7 @@ namespace JSONRPC static JSONRPC_STATUS GetGenres(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetMovieDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static JSONRPC_STATUS SetMovieSetDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetTVShowDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetSeasonDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS SetEpisodeDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); diff --git a/xbmc/interfaces/json-rpc/methods.json b/xbmc/interfaces/json-rpc/methods.json index 33248c54bd..3b51be1551 100644 --- a/xbmc/interfaces/json-rpc/methods.json +++ b/xbmc/interfaces/json-rpc/methods.json @@ -1306,6 +1306,18 @@ ], "returns": "string" }, + "VideoLibrary.SetMovieSetDetails": { + "type": "method", + "description": "Update the given movie set with the given details", + "transport": "Response", + "permission": "UpdateData", + "params": [ + { "name": "setid", "$ref": "Library.Id", "required": true }, + { "name": "title", "$ref": "Optional.String" }, + { "name": "art", "type": [ "null", { "$ref": "Media.Artwork.Set", "required": true } ], "default": null } + ], + "returns": "string" + }, "VideoLibrary.SetTVShowDetails": { "type": "method", "description": "Update the given tvshow with the given details", diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 3fa5a1a6e4..b78b9da702 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -2111,6 +2111,41 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con return -1; } +int CVideoDatabase::SetDetailsForMovieSet(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idSet /* = -1 */) +{ + if (details.m_strTitle.empty()) + return -1; + + try + { + BeginTransaction(); + if (idSet < 0) + { + idSet = AddSet(details.m_strTitle); + if (idSet < 0) + { + RollbackTransaction(); + return -1; + } + } + + SetArtForItem(idSet, "set", artwork); + + // and insert the new row + CStdString sql = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", details.m_strTitle.c_str(), idSet); + m_pDS->exec(sql.c_str()); + CommitTransaction(); + + return idSet; + } + catch (...) + { + CLog::Log(LOGERROR, "%s (%i) failed", __FUNCTION__, idSet); + } + RollbackTransaction(); + return -1; +} + int CVideoDatabase::SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details, const map<string, string> &artwork, const map<int, map<string, string> > &seasonArt, int idTvShow /*= -1 */) { try diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index acd8bb7da1..4a78bd636f 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -446,6 +446,7 @@ public: void GetEpisodesByFile(const CStdString& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes); int SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMovie = -1); + int SetDetailsForMovieSet(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idSet = -1); int SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt, int idTvShow = -1); int SetDetailsForSeason(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idSeason = -1); int SetDetailsForEpisode(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idEpisode=-1); |