Permalink
Browse files

jsonrpc: added Set(Movie|TVShow|Episode|MusicVideo)Details and Remove…

…(Movie|TVShow|Episode|MusicVideo) to VideoLibrary namespace
  • Loading branch information...
1 parent d1e06c2 commit bb569bb39b63f4b11bda3ac16d899e140a422c1e @Montellese committed Apr 26, 2011
View
8 xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
@@ -164,6 +164,14 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {
{ "VideoLibrary.GetRecentlyAddedMovies", CVideoLibrary::GetRecentlyAddedMovies },
{ "VideoLibrary.GetRecentlyAddedEpisodes", CVideoLibrary::GetRecentlyAddedEpisodes },
{ "VideoLibrary.GetRecentlyAddedMusicVideos", CVideoLibrary::GetRecentlyAddedMusicVideos },
+ { "VideoLibrary.SetMovieDetails", CVideoLibrary::SetMovieDetails },
+ { "VideoLibrary.SetTVShowDetails", CVideoLibrary::SetTVShowDetails },
+ { "VideoLibrary.SetEpisodeDetails", CVideoLibrary::SetEpisodeDetails },
+ { "VideoLibrary.SetMusicVideoDetails", CVideoLibrary::SetMusicVideoDetails },
+ { "VideoLibrary.RemoveMovie", CVideoLibrary::RemoveMovie },
+ { "VideoLibrary.RemoveTVShow", CVideoLibrary::RemoveTVShow },
+ { "VideoLibrary.RemoveEpisode", CVideoLibrary::RemoveEpisode },
+ { "VideoLibrary.RemoveMusicVideo", CVideoLibrary::RemoveMusicVideo },
{ "VideoLibrary.Scan", CVideoLibrary::Scan },
{ "VideoLibrary.Export", CVideoLibrary::Export },
{ "VideoLibrary.Clean", CVideoLibrary::Clean },
View
18 xbmc/interfaces/json-rpc/JSONUtils.h
@@ -374,5 +374,23 @@ namespace JSONRPC
}
static inline bool HasType(JSONSchemaType typeObject, JSONSchemaType type) { return (typeObject & type) == type; }
+
+ static inline bool ParameterNotNull(const CVariant &parameterObject, std::string key) { return parameterObject.isMember(key) && !parameterObject[key].isNull(); }
+
+ /*!
+ \brief Copies the values from the jsonStringArray to the stringArray.
+ stringArray is cleared.
+ \param jsonStringArray JSON object representing a string array
+ \param stringArray String array where the values are copied into (cleared)
+ */
+ static void CopyStringArray(const CVariant &jsonStringArray, std::vector<std::string> &stringArray)
+ {
+ if (!jsonStringArray.isArray())
+ return;
+
+ stringArray.clear();
+ for (CVariant::const_iterator_array it = jsonStringArray.begin_array(); it != jsonStringArray.end_array(); it++)
+ stringArray.push_back(it->asString());
+ }
};
}
View
156 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -31,6 +31,18 @@ namespace JSONRPC
"\"type\": [ \"null\", \"boolean\" ],"
"\"default\": null"
"}",
+ "\"Optional.String\": {"
+ "\"type\": [ \"null\", \"string\" ], "
+ "\"default\": null"
+ "}",
+ "\"Optional.Integer\": {"
+ "\"type\": [ \"null\", \"integer\" ], "
+ "\"default\": null"
+ "}",
+ "\"Optional.Number\": {"
+ "\"type\": [ \"null\", \"number\" ], "
+ "\"default\": null"
+ "}",
"\"Array.String\": {"
"\"type\": \"array\","
"\"items\": { \"type\": \"string\", \"minLength\": 1 }"
@@ -1964,6 +1976,150 @@ namespace JSONRPC
"}"
"}"
"}",
+ "\"VideoLibrary.SetMovieDetails\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Update the given movie with the given details\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"UpdateData\","
+ "\"params\": ["
+ "{ \"name\": \"movieid\", \"$ref\": \"Library.Id\", \"required\": true },"
+ "{ \"name\": \"title\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"playcount\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"runtime\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"director\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"studio\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"year\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"plot\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"genre\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"rating\", \"$ref\": \"Optional.Number\" },"
+ "{ \"name\": \"mpaa\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"imdbnumber\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"votes\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"lastplayed\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"originaltitle\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"trailer\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"tagline\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"plotoutline\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"writer\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"country\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"top250\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"sorttitle\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"set\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"showlink\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.SetTVShowDetails\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Update the given tvshow with the given details\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"UpdateData\","
+ "\"params\": ["
+ "{ \"name\": \"tvshowid\", \"$ref\": \"Library.Id\", \"required\": true },"
+ "{ \"name\": \"title\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"playcount\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"studio\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"year\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"plot\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"genre\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"rating\", \"$ref\": \"Optional.Number\" },"
+ "{ \"name\": \"mpaa\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"imdbnumber\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"premiered\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"votes\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"lastplayed\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"originaltitle\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"sorttitle\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"episodeguide\", \"$ref\": \"Optional.String\" }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.SetEpisodeDetails\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Update the given episode with the given details\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"UpdateData\","
+ "\"params\": ["
+ "{ \"name\": \"episodeid\", \"$ref\": \"Library.Id\", \"required\": true },"
+ "{ \"name\": \"title\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"playcount\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"runtime\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"director\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"plot\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"rating\", \"$ref\": \"Optional.Number\" },"
+ "{ \"name\": \"votes\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"lastplayed\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"writer\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"firstaired\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"productioncode\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"season\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"episode\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"originaltitle\", \"$ref\": \"Optional.String\" }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.SetMusicVideoDetails\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Update the given music video with the given details\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"UpdateData\","
+ "\"params\": ["
+ "{ \"name\": \"musicvideoid\", \"$ref\": \"Library.Id\", \"required\": true },"
+ "{ \"name\": \"title\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"playcount\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"runtime\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"director\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"studio\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"year\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"plot\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"album\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"artist\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"genre\", \"type\": [ \"null\", \"Array.String\" ], \"default\": null },"
+ "{ \"name\": \"track\", \"$ref\": \"Optional.Integer\" },"
+ "{ \"name\": \"lastplayed\", \"$ref\": \"Optional.String\" }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.RemoveMovie\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Removes the given movie from the library\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"RemoveData\","
+ "\"params\": ["
+ "{ \"name\": \"movieid\", \"$ref\": \"Library.Id\", \"required\": true }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.RemoveTVShow\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Removes the given tv show from the library\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"RemoveData\","
+ "\"params\": ["
+ "{ \"name\": \"tvshowid\", \"$ref\": \"Library.Id\", \"required\": true }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.RemoveEpisode\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Removes the given episode from the library\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"RemoveData\","
+ "\"params\": ["
+ "{ \"name\": \"episodeid\", \"$ref\": \"Library.Id\", \"required\": true }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
+ "\"VideoLibrary.RemoveMusicVideo\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Removes the given music video from the library\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"RemoveData\","
+ "\"params\": ["
+ "{ \"name\": \"musicvideoid\", \"$ref\": \"Library.Id\", \"required\": true }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
"\"VideoLibrary.Scan\": {"
"\"type\": \"method\","
"\"description\": \"Scans the video sources for new library items\","
View
236 xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -348,6 +348,157 @@ JSONRPC_STATUS CVideoLibrary::GetGenres(const CStdString &method, ITransportLaye
return OK;
}
+JSONRPC_STATUS CVideoLibrary::SetMovieDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ int id = (int)parameterObject["movieid"].asInteger();
+
+ CVideoDatabase videodatabase;
+ if (!videodatabase.Open())
+ return InternalError;
+
+ CVideoInfoTag infos;
+ videodatabase.GetMovieInfo("", infos, id);
+ if (infos.m_iDbId <= 0)
+ {
+ videodatabase.Close();
+ return InvalidParams;
+ }
+
+ int playcount = infos.m_playCount;
+ CDateTime lastPlayed = infos.m_lastPlayed;
+
+ UpdateVideoTag(parameterObject, infos);
+
+ if (videodatabase.SetDetailsForMovie(infos.m_strFileNameAndPath, infos, id) > 0)
+ {
+ if (playcount != infos.m_playCount || lastPlayed != infos.m_lastPlayed)
+ videodatabase.SetPlayCount(CFileItem(infos), infos.m_playCount, infos.m_lastPlayed);
+ return ACK;
+ }
+
+ return InternalError;
+}
+
+JSONRPC_STATUS CVideoLibrary::SetTVShowDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ int id = (int)parameterObject["tvshowid"].asInteger();
+
+ CVideoDatabase videodatabase;
+ if (!videodatabase.Open())
+ return InternalError;
+
+ CVideoInfoTag infos;
+ videodatabase.GetTvShowInfo("", infos, id);
+ if (infos.m_iDbId <= 0)
+ {
+ videodatabase.Close();
+ return InvalidParams;
+ }
+
+ int playcount = infos.m_playCount;
+ CDateTime lastPlayed = infos.m_lastPlayed;
+
+ UpdateVideoTag(parameterObject, infos);
+
+ if (videodatabase.SetDetailsForTvShow(infos.m_strFileNameAndPath, infos, id) > 0)
+ {
+ if (playcount != infos.m_playCount || lastPlayed != infos.m_lastPlayed)
+ videodatabase.SetPlayCount(CFileItem(infos), infos.m_playCount, infos.m_lastPlayed);
+ return ACK;
+ }
+
+ return InternalError;
+}
+
+JSONRPC_STATUS CVideoLibrary::SetEpisodeDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ int id = (int)parameterObject["episodeid"].asInteger();
+
+ CVideoDatabase videodatabase;
+ if (!videodatabase.Open())
+ return InternalError;
+
+ CVideoInfoTag infos;
+ videodatabase.GetEpisodeInfo("", infos, id);
+ if (infos.m_iDbId <= 0)
+ {
+ videodatabase.Close();
+ return InvalidParams;
+ }
+
+ int tvshowid = videodatabase.GetTvShowForEpisode(id);
+ if (tvshowid <= 0)
+ {
+ videodatabase.Close();
+ return InvalidParams;
+ }
+
+ int playcount = infos.m_playCount;
+ CDateTime lastPlayed = infos.m_lastPlayed;
+
+ UpdateVideoTag(parameterObject, infos);
+
+ if (videodatabase.SetDetailsForEpisode(infos.m_strFileNameAndPath, infos, tvshowid, id) > 0)
+ {
+ if (playcount != infos.m_playCount || lastPlayed != infos.m_lastPlayed)
+ videodatabase.SetPlayCount(CFileItem(infos), infos.m_playCount, infos.m_lastPlayed);
+ return ACK;
+ }
+
+ return InternalError;
+}
+
+JSONRPC_STATUS CVideoLibrary::SetMusicVideoDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ int id = (int)parameterObject["musicvideoid"].asInteger();
+
+ CVideoDatabase videodatabase;
+ if (!videodatabase.Open())
+ return InternalError;
+
+ CVideoInfoTag infos;
+ videodatabase.GetMusicVideoInfo("", infos, id);
+ if (infos.m_iDbId <= 0)
+ {
+ videodatabase.Close();
+ return InvalidParams;
+ }
+
+ int playcount = infos.m_playCount;
+ CDateTime lastPlayed = infos.m_lastPlayed;
+
+ UpdateVideoTag(parameterObject, infos);
+
+ if (videodatabase.SetDetailsForMusicVideo(infos.m_strFileNameAndPath, infos, id) > 0)
+ {
+ if (playcount != infos.m_playCount || lastPlayed != infos.m_lastPlayed)
+ videodatabase.SetPlayCount(CFileItem(infos), infos.m_playCount, infos.m_lastPlayed);
+ return ACK;
+ }
+
+ return InternalError;
+}
+
+JSONRPC_STATUS CVideoLibrary::RemoveMovie(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ return RemoveVideo(parameterObject);
+}
+
+JSONRPC_STATUS CVideoLibrary::RemoveTVShow(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ return RemoveVideo(parameterObject);
+}
+
+JSONRPC_STATUS CVideoLibrary::RemoveEpisode(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ return RemoveVideo(parameterObject);
+}
+
+JSONRPC_STATUS CVideoLibrary::RemoveMusicVideo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ return RemoveVideo(parameterObject);
+}
+
JSONRPC_STATUS CVideoLibrary::Scan(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
std::string directory = parameterObject["directory"].asString();
@@ -524,3 +675,88 @@ JSONRPC_STATUS CVideoLibrary::GetAdditionalMusicVideoDetails(const CVariant &par
return OK;
}
+
+JSONRPC_STATUS CVideoLibrary::RemoveVideo(const CVariant &parameterObject)
+{
+ CVideoDatabase videodatabase;
+ if (!videodatabase.Open())
+ return InternalError;
+
+ if (parameterObject.isMember("movieid"))
+ videodatabase.DeleteMovie((int)parameterObject["movieid"].asInteger());
+ else if (parameterObject.isMember("tvshowid"))
+ videodatabase.DeleteTvShow((int)parameterObject["tvshowid"].asInteger());
+ else if (parameterObject.isMember("episodeid"))
+ videodatabase.DeleteEpisode((int)parameterObject["episodeid"].asInteger());
+ else if (parameterObject.isMember("musicvideoid"))
+ videodatabase.DeleteMusicVideo((int)parameterObject["musicvideoid"].asInteger());
+ return ACK;
+}
+
+void CVideoLibrary::UpdateVideoTag(const CVariant &parameterObject, CVideoInfoTag& details)
+{
+ if (ParameterNotNull(parameterObject, "title"))
+ details.m_strTitle = parameterObject["title"].asString();
+ if (ParameterNotNull(parameterObject, "playcount"))
+ details.m_playCount = (int)parameterObject["playcount"].asInteger();
+ if (ParameterNotNull(parameterObject, "runtime"))
+ details.m_strRuntime = parameterObject["runtime"].asString();
+ if (ParameterNotNull(parameterObject, "director"))
+ CopyStringArray(parameterObject["director"], details.m_director);
+ if (ParameterNotNull(parameterObject, "studio"))
+ CopyStringArray(parameterObject["studio"], details.m_studio);
+ if (ParameterNotNull(parameterObject, "year"))
+ details.m_iYear = (int)parameterObject["year"].asInteger();
+ if (ParameterNotNull(parameterObject, "plot"))
+ details.m_strPlot = parameterObject["plot"].asString();
+ if (ParameterNotNull(parameterObject, "album"))
+ details.m_strAlbum = parameterObject["album"].asString();
+ if (ParameterNotNull(parameterObject, "artist"))
+ details.m_strArtist = parameterObject["artist"].asString();
+ if (ParameterNotNull(parameterObject, "genre"))
+ CopyStringArray(parameterObject["genre"], details.m_genre);
+ if (ParameterNotNull(parameterObject, "track"))
+ details.m_iTrack = (int)parameterObject["track"].asInteger();
+ if (ParameterNotNull(parameterObject, "rating"))
+ details.m_fRating = parameterObject["rating"].asFloat();
+ if (ParameterNotNull(parameterObject, "mpaa"))
+ details.m_strMPAARating = parameterObject["mpaa"].asString();
+ if (ParameterNotNull(parameterObject, "imdbnumber"))
+ details.m_strIMDBNumber = parameterObject["imdbnumber"].asString();
+ if (ParameterNotNull(parameterObject, "premiered"))
+ details.m_premiered.SetFromDBDate(parameterObject["premiered"].asString());
+ if (ParameterNotNull(parameterObject, "votes"))
+ details.m_strVotes = parameterObject["votes"].asString();
+ if (ParameterNotNull(parameterObject, "lastplayed"))
+ details.m_lastPlayed.SetFromDBDateTime(parameterObject["lastplayed"].asString());
+ if (ParameterNotNull(parameterObject, "firstaired"))
+ details.m_firstAired.SetFromDBDateTime(parameterObject["firstaired"].asString());
+ if (ParameterNotNull(parameterObject, "productioncode"))
+ details.m_strProductionCode = parameterObject["productioncode"].asString();
+ if (ParameterNotNull(parameterObject, "season"))
+ details.m_iSeason = (int)parameterObject["season"].asInteger();
+ if (ParameterNotNull(parameterObject, "episode"))
+ details.m_iEpisode = (int)parameterObject["episode"].asInteger();
+ if (ParameterNotNull(parameterObject, "originaltitle"))
+ details.m_strOriginalTitle = parameterObject["originaltitle"].asString();
+ if (ParameterNotNull(parameterObject, "trailer"))
+ details.m_strTrailer = parameterObject["trailer"].asString();
+ if (ParameterNotNull(parameterObject, "tagline"))
+ details.m_strTagLine = parameterObject["tagline"].asString();
+ if (ParameterNotNull(parameterObject, "plotoutline"))
+ details.m_strPlotOutline = parameterObject["plotoutline"].asString();
+ if (ParameterNotNull(parameterObject, "writer"))
+ CopyStringArray(parameterObject["writer"], details.m_writingCredits);
+ if (ParameterNotNull(parameterObject, "country"))
+ CopyStringArray(parameterObject["country"], details.m_country);
+ if (ParameterNotNull(parameterObject, "top250"))
+ details.m_iTop250 = (int)parameterObject["top250"].asInteger();
+ if (ParameterNotNull(parameterObject, "sorttitle"))
+ details.m_strSortTitle = parameterObject["sorttitle"].asString();
+ if (ParameterNotNull(parameterObject, "episodeguide"))
+ details.m_strEpisodeGuide = parameterObject["episodeguide"].asString();
+ if (ParameterNotNull(parameterObject, "set"))
+ CopyStringArray(parameterObject["set"], details.m_set);
+ if (ParameterNotNull(parameterObject, "showlink"))
+ CopyStringArray(parameterObject["showlink"], details.m_showLink);
+}
View
12 xbmc/interfaces/json-rpc/VideoLibrary.h
@@ -51,6 +51,16 @@ namespace JSONRPC
static JSONRPC_STATUS GetGenres(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS SetMovieDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS SetTVShowDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS SetEpisodeDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS SetMusicVideoDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+
+ static JSONRPC_STATUS RemoveMovie(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS RemoveTVShow(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS RemoveEpisode(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS RemoveMusicVideo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+
static JSONRPC_STATUS Scan(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Export(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Clean(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
@@ -62,5 +72,7 @@ namespace JSONRPC
static JSONRPC_STATUS GetAdditionalMovieDetails(const CVariant &parameterObject, CFileItemList &items, CVariant &result, CVideoDatabase &videodatabase);
static JSONRPC_STATUS GetAdditionalEpisodeDetails(const CVariant &parameterObject, CFileItemList &items, CVariant &result, CVideoDatabase &videodatabase);
static JSONRPC_STATUS GetAdditionalMusicVideoDetails(const CVariant &parameterObject, CFileItemList &items, CVariant &result, CVideoDatabase &videodatabase);
+ static JSONRPC_STATUS RemoveVideo(const CVariant &parameterObject);
+ static void UpdateVideoTag(const CVariant &parameterObject, CVideoInfoTag& details);
};
}
View
144 xbmc/interfaces/json-rpc/methods.json
@@ -1115,6 +1115,150 @@
}
}
},
+ "VideoLibrary.SetMovieDetails": {
+ "type": "method",
+ "description": "Update the given movie with the given details",
+ "transport": "Response",
+ "permission": "UpdateData",
+ "params": [
+ { "name": "movieid", "$ref": "Library.Id", "required": true },
+ { "name": "title", "$ref": "Optional.String" },
+ { "name": "playcount", "$ref": "Optional.Integer" },
+ { "name": "runtime", "$ref": "Optional.String" },
+ { "name": "director", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "studio", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "year", "$ref": "Optional.Integer" },
+ { "name": "plot", "$ref": "Optional.String" },
+ { "name": "genre", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "rating", "$ref": "Optional.Number" },
+ { "name": "mpaa", "$ref": "Optional.String" },
+ { "name": "imdbnumber", "$ref": "Optional.String" },
+ { "name": "votes", "$ref": "Optional.String" },
+ { "name": "lastplayed", "$ref": "Optional.String" },
+ { "name": "originaltitle", "$ref": "Optional.String" },
+ { "name": "trailer", "$ref": "Optional.String" },
+ { "name": "tagline", "$ref": "Optional.String" },
+ { "name": "plotoutline", "$ref": "Optional.String" },
+ { "name": "writer", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "country", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "top250", "$ref": "Optional.Integer" },
+ { "name": "sorttitle", "$ref": "Optional.String" },
+ { "name": "set", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "showlink", "type": [ "null", "Array.String" ], "default": null }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.SetTVShowDetails": {
+ "type": "method",
+ "description": "Update the given tvshow with the given details",
+ "transport": "Response",
+ "permission": "UpdateData",
+ "params": [
+ { "name": "tvshowid", "$ref": "Library.Id", "required": true },
+ { "name": "title", "$ref": "Optional.String" },
+ { "name": "playcount", "$ref": "Optional.Integer" },
+ { "name": "studio", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "year", "$ref": "Optional.Integer" },
+ { "name": "plot", "$ref": "Optional.String" },
+ { "name": "genre", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "rating", "$ref": "Optional.Number" },
+ { "name": "mpaa", "$ref": "Optional.String" },
+ { "name": "imdbnumber", "$ref": "Optional.String" },
+ { "name": "premiered", "$ref": "Optional.String" },
+ { "name": "votes", "$ref": "Optional.String" },
+ { "name": "lastplayed", "$ref": "Optional.String" },
+ { "name": "originaltitle", "$ref": "Optional.String" },
+ { "name": "sorttitle", "$ref": "Optional.String" },
+ { "name": "episodeguide", "$ref": "Optional.String" }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.SetEpisodeDetails": {
+ "type": "method",
+ "description": "Update the given episode with the given details",
+ "transport": "Response",
+ "permission": "UpdateData",
+ "params": [
+ { "name": "episodeid", "$ref": "Library.Id", "required": true },
+ { "name": "title", "$ref": "Optional.String" },
+ { "name": "playcount", "$ref": "Optional.Integer" },
+ { "name": "runtime", "$ref": "Optional.String" },
+ { "name": "director", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "plot", "$ref": "Optional.String" },
+ { "name": "rating", "$ref": "Optional.Number" },
+ { "name": "votes", "$ref": "Optional.String" },
+ { "name": "lastplayed", "$ref": "Optional.String" },
+ { "name": "writer", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "firstaired", "$ref": "Optional.String" },
+ { "name": "productioncode", "$ref": "Optional.String" },
+ { "name": "season", "$ref": "Optional.Integer" },
+ { "name": "episode", "$ref": "Optional.Integer" },
+ { "name": "originaltitle", "$ref": "Optional.String" }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.SetMusicVideoDetails": {
+ "type": "method",
+ "description": "Update the given music video with the given details",
+ "transport": "Response",
+ "permission": "UpdateData",
+ "params": [
+ { "name": "musicvideoid", "$ref": "Library.Id", "required": true },
+ { "name": "title", "$ref": "Optional.String" },
+ { "name": "playcount", "$ref": "Optional.Integer" },
+ { "name": "runtime", "$ref": "Optional.String" },
+ { "name": "director", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "studio", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "year", "$ref": "Optional.Integer" },
+ { "name": "plot", "$ref": "Optional.String" },
+ { "name": "album", "$ref": "Optional.String" },
+ { "name": "artist", "$ref": "Optional.String" },
+ { "name": "genre", "type": [ "null", "Array.String" ], "default": null },
+ { "name": "track", "$ref": "Optional.Integer" },
+ { "name": "lastplayed", "$ref": "Optional.String" }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.RemoveMovie": {
+ "type": "method",
+ "description": "Removes the given movie from the library",
+ "transport": "Response",
+ "permission": "RemoveData",
+ "params": [
+ { "name": "movieid", "$ref": "Library.Id", "required": true }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.RemoveTVShow": {
+ "type": "method",
+ "description": "Removes the given tv show from the library",
+ "transport": "Response",
+ "permission": "RemoveData",
+ "params": [
+ { "name": "tvshowid", "$ref": "Library.Id", "required": true }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.RemoveEpisode": {
+ "type": "method",
+ "description": "Removes the given episode from the library",
+ "transport": "Response",
+ "permission": "RemoveData",
+ "params": [
+ { "name": "episodeid", "$ref": "Library.Id", "required": true }
+ ],
+ "returns": "string"
+ },
+ "VideoLibrary.RemoveMusicVideo": {
+ "type": "method",
+ "description": "Removes the given music video from the library",
+ "transport": "Response",
+ "permission": "RemoveData",
+ "params": [
+ { "name": "musicvideoid", "$ref": "Library.Id", "required": true }
+ ],
+ "returns": "string"
+ },
"VideoLibrary.Scan": {
"type": "method",
"description": "Scans the video sources for new library items",
View
12 xbmc/interfaces/json-rpc/types.json
@@ -3,6 +3,18 @@
"type": [ "null", "boolean" ],
"default": null
},
+ "Optional.String": {
+ "type": [ "null", "string" ],
+ "default": null
+ },
+ "Optional.Integer": {
+ "type": [ "null", "integer" ],
+ "default": null
+ },
+ "Optional.Number": {
+ "type": [ "null", "number" ],
+ "default": null
+ },
"Array.String": {
"type": "array",
"items": { "type": "string", "minLength": 1 }
View
143 xbmc/video/VideoDatabase.cpp
@@ -1774,21 +1774,29 @@ CStdString CVideoDatabase::GetValueString(const CVideoInfoTag &details, int min,
}
//********************************************************************************************************************************
-int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details)
+int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, int idMovie /* = -1 */)
{
try
{
- int idMovie = GetMovieId(strFilenameAndPath);
- if (idMovie > -1)
- DeleteMovie(strFilenameAndPath, true); // true to keep the table entry
-
BeginTransaction();
- idMovie = AddMovie(strFilenameAndPath);
if (idMovie < 0)
{
- CommitTransaction();
- return idMovie;
+ idMovie = GetMovieId(strFilenameAndPath);
+ if (idMovie > -1)
+ DeleteMovie(strFilenameAndPath, true, true, idMovie); // true to keep the table entry and the thumb
+ else
+ {
+ // only add a new movie if we don't already have a valid idMovie
+ // (DeleteMovie is called with bKeepId == true so the movie won't
+ // be removed from the movie table)
+ idMovie = AddMovie(strFilenameAndPath);
+ if (idMovie < 0)
+ {
+ CommitTransaction();
+ return idMovie;
+ }
+ }
}
vector<int> vecDirectors;
@@ -1844,7 +1852,7 @@ int CVideoDatabase::SetDetailsForMovie(const CStdString& strFilenameAndPath, con
return -1;
}
-int CVideoDatabase::SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details)
+int CVideoDatabase::SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details, int idTvShow /*= -1 */)
{
try
{
@@ -1856,9 +1864,12 @@ int CVideoDatabase::SetDetailsForTvShow(const CStdString& strPath, const CVideoI
BeginTransaction();
- int idTvShow = GetTvShowId(strPath);
if (idTvShow < 0)
- idTvShow = AddTvShow(strPath);
+ {
+ idTvShow = GetTvShowId(strPath);
+ if (idTvShow < 0)
+ idTvShow = AddTvShow(strPath);
+ }
vector<int> vecDirectors;
vector<int> vecGenres;
@@ -1914,13 +1925,18 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c
{
idEpisode = GetEpisodeId(strFilenameAndPath);
if (idEpisode > 0)
- DeleteEpisode(strFilenameAndPath,idEpisode);
-
- idEpisode = AddEpisode(idShow,strFilenameAndPath);
- if (idEpisode < 0)
+ DeleteEpisode(strFilenameAndPath, idEpisode, true, true); // true to keep the table entry and the thumb
+ else
{
- CommitTransaction();
- return -1;
+ // only add a new episode if we don't already have a valid idEpisode
+ // (DeleteEpisode is called with bKeepId == true so the episode won't
+ // be removed from the episode table)
+ idEpisode = AddEpisode(idShow,strFilenameAndPath);
+ if (idEpisode < 0)
+ {
+ CommitTransaction();
+ return -1;
+ }
}
}
@@ -1969,22 +1985,29 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c
return -1;
}
-int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details)
+int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, int idMVideo /* = -1 */)
{
try
{
BeginTransaction();
- int idMVideo = GetMusicVideoId(strFilenameAndPath);
- if (idMVideo > -1)
- {
- DeleteMusicVideo(strFilenameAndPath);
- }
- idMVideo = AddMusicVideo(strFilenameAndPath);
if (idMVideo < 0)
{
- CommitTransaction();
- return -1;
+ idMVideo = GetMusicVideoId(strFilenameAndPath);
+ if (idMVideo > -1)
+ DeleteMusicVideo(strFilenameAndPath, true, true, idMVideo); // Keep id and thumb
+ else
+ {
+ // only add a new musicvideo if we don't already have a valid idMVideo
+ // (DeleteMusicVideo is called with bKeepId == true so the musicvideo won't
+ // be removed from the musicvideo table)
+ idMVideo = AddMusicVideo(strFilenameAndPath);
+ if (idMVideo < 0)
+ {
+ CommitTransaction();
+ return -1;
+ }
+ }
}
vector<int> vecDirectors;
@@ -2403,16 +2426,28 @@ void CVideoDatabase::DeleteBookMarkForEpisode(const CVideoInfoTag& tag)
}
//********************************************************************************************************************************
-void CVideoDatabase::DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+void CVideoDatabase::DeleteMovie(int idMovie, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+{
+ if (idMovie < 0)
+ return;
+
+ CStdString path;
+ GetFilePathById(idMovie, path, VIDEODB_CONTENT_MOVIES);
+ if (!path.empty())
+ DeleteMovie(path, bKeepId, bKeepThumb, idMovie);
+}
+
+void CVideoDatabase::DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */, int idMovie /* = -1 */)
{
try
{
if (NULL == m_pDB.get()) return ;
if (NULL == m_pDS.get()) return ;
- int idMovie = GetMovieId(strFilenameAndPath);
if (idMovie < 0)
{
- return ;
+ idMovie = GetMovieId(strFilenameAndPath);
+ if (idMovie < 0)
+ return;
}
BeginTransaction();
@@ -2469,17 +2504,28 @@ void CVideoDatabase::DeleteMovie(const CStdString& strFilenameAndPath, bool bKee
}
}
-void CVideoDatabase::DeleteTvShow(const CStdString& strPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+void CVideoDatabase::DeleteTvShow(int idTvShow, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+{
+ if (idTvShow < 0)
+ return;
+
+ CStdString path;
+ GetFilePathById(idTvShow, path, VIDEODB_CONTENT_TVSHOWS);
+ if (!path.empty())
+ DeleteTvShow(path, bKeepId, bKeepThumb, idTvShow);
+}
+
+void CVideoDatabase::DeleteTvShow(const CStdString& strPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */, int idTvShow /* = -1 */)
{
try
{
- int idTvShow=-1;
if (NULL == m_pDB.get()) return ;
if (NULL == m_pDS.get()) return ;
- idTvShow = GetTvShowId(strPath);
if (idTvShow < 0)
{
- return ;
+ idTvShow = GetTvShowId(strPath);
+ if (idTvShow < 0)
+ return;
}
BeginTransaction();
@@ -2537,7 +2583,18 @@ void CVideoDatabase::DeleteTvShow(const CStdString& strPath, bool bKeepId /* = f
}
}
-void CVideoDatabase::DeleteEpisode(const CStdString& strFilenameAndPath, int idEpisode, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+void CVideoDatabase::DeleteEpisode(int idEpisode, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+{
+ if (idEpisode < 0)
+ return;
+
+ CStdString path;
+ GetFilePathById(idEpisode, path, VIDEODB_CONTENT_EPISODES);
+ if (!path.empty())
+ DeleteEpisode(path, idEpisode, bKeepId, bKeepThumb);
+}
+
+void CVideoDatabase::DeleteEpisode(const CStdString& strFilenameAndPath, int idEpisode /* = -1 */, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
{
try
{
@@ -2586,16 +2643,28 @@ void CVideoDatabase::DeleteEpisode(const CStdString& strFilenameAndPath, int idE
}
}
-void CVideoDatabase::DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+void CVideoDatabase::DeleteMusicVideo(int idMusicVideo, bool bKeepId /* = false */, bool bKeepThumb /* = false */)
+{
+ if (idMusicVideo < 0)
+ return;
+
+ CStdString path;
+ GetFilePathById(idMusicVideo, path, VIDEODB_CONTENT_MUSICVIDEOS);
+ if (!path.empty())
+ DeleteMusicVideo(path, bKeepId, bKeepThumb, idMusicVideo);
+}
+
+void CVideoDatabase::DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId /* = false */, bool bKeepThumb /* = false */, int idMVideo /* = -1 */)
{
try
{
if (NULL == m_pDB.get()) return ;
if (NULL == m_pDS.get()) return ;
- int idMVideo = GetMusicVideoId(strFilenameAndPath);
if (idMVideo < 0)
{
- return ;
+ idMVideo = GetMusicVideoId(strFilenameAndPath);
+ if (idMVideo < 0)
+ return;
}
BeginTransaction();
View
16 xbmc/video/VideoDatabase.h
@@ -404,18 +404,22 @@ class CVideoDatabase : public CDatabase
void GetEpisodesByFile(const CStdString& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes);
- int SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details);
- int SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details);
+ int SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, int idMovie = -1);
+ int SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details, int idTvShow = -1);
int SetDetailsForEpisode(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, int idShow, int idEpisode=-1);
- int SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details);
+ int SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, int idMVideo = -1);
void SetStreamDetailsForFile(const CStreamDetails& details, const CStdString &strFileNameAndPath);
void SetStreamDetailsForFileId(const CStreamDetails& details, int idFile);
void SetDetail(const CStdString& strDetail, int id, int field, VIDEODB_CONTENT_TYPE type);
- void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false, bool bKeepThumb = false);
- void DeleteTvShow(const CStdString& strPath, bool bKeepId = false, bool bKeepThumb = false);
+ void DeleteMovie(int idMovie, bool bKeepId = false, bool bKeepThumb = false);
+ void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false, bool bKeepThumb = false, int idMovie = -1);
+ void DeleteTvShow(int idTvShow, bool bKeepId = false, bool bKeepThumb = false);
+ void DeleteTvShow(const CStdString& strPath, bool bKeepId = false, bool bKeepThumb = false, int idTvShow = -1);
+ void DeleteEpisode(int idEpisode, bool bKeepId = false, bool bKeepThumb = false);
void DeleteEpisode(const CStdString& strFilenameAndPath, int idEpisode = -1, bool bKeepId = false, bool bKeepThumb = false);
- void DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId = false, bool bKeepThumb = false);
+ void DeleteMusicVideo(int idMusicVideo, bool bKeepId = false, bool bKeepThumb = false);
+ void DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId = false, bool bKeepThumb = false, int idMVideo = -1);
void DeleteDetailsForTvShow(const CStdString& strPath);
void RemoveContentForPath(const CStdString& strPath,CGUIDialogProgress *progress = NULL);
void UpdateFanart(const CFileItem &item, VIDEODB_CONTENT_TYPE type);

0 comments on commit bb569bb

Please sign in to comment.