Skip to content

Commit

Permalink
Add a method to retrieve video tags
Browse files Browse the repository at this point in the history
  • Loading branch information
phate89 committed Jun 2, 2016
1 parent 2a99ea0 commit 5ac6aab
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {

// Video Library
{ "VideoLibrary.GetGenres", CVideoLibrary::GetGenres },
{ "VideoLibrary.GetTags", CVideoLibrary::GetTags },
{ "VideoLibrary.GetMovies", CVideoLibrary::GetMovies },
{ "VideoLibrary.GetMovieDetails", CVideoLibrary::GetMovieDetails },
{ "VideoLibrary.GetMovieSets", CVideoLibrary::GetMovieSets },
Expand Down
41 changes: 41 additions & 0 deletions xbmc/interfaces/json-rpc/VideoLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,47 @@ JSONRPC_STATUS CVideoLibrary::GetGenres(const std::string &method, ITransportLay
return OK;
}

JSONRPC_STATUS CVideoLibrary::GetTags(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
std::string media = parameterObject["type"].asString();
StringUtils::ToLower(media);
int idContent = -1;

std::string strPath = "videodb://";
/* select which video content to get tags from*/
if (media == MediaTypeMovie)
{
idContent = VIDEODB_CONTENT_MOVIES;
strPath += "movies";
}
else if (media == MediaTypeTvShow)
{
idContent = VIDEODB_CONTENT_TVSHOWS;
strPath += "tvshows";
}
else if (media == MediaTypeMusicVideo)
{
idContent = VIDEODB_CONTENT_MUSICVIDEOS;
strPath += "musicvideos";
}
strPath += "/tags/";

CVideoDatabase videodatabase;
if (!videodatabase.Open())
return InternalError;

CFileItemList items;
if (!videodatabase.GetTagsNav(strPath, items, idContent))
return InternalError;

/* need to set strTitle in each item*/
for (int i = 0; i < items.Size(); i++)
items[i]->GetVideoInfoTag()->m_strTitle = items[i]->GetLabel();

HandleFileItemList("tagid", false, "tags", items, parameterObject, result);
return OK;
}

JSONRPC_STATUS CVideoLibrary::SetMovieDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
int id = (int)parameterObject["movieid"].asInteger();
Expand Down
1 change: 1 addition & 0 deletions xbmc/interfaces/json-rpc/VideoLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace JSONRPC
static JSONRPC_STATUS GetInProgressTVShows(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);

static JSONRPC_STATUS GetGenres(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS GetTags(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);

static JSONRPC_STATUS SetMovieDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetMovieSetDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
Expand Down
21 changes: 21 additions & 0 deletions xbmc/interfaces/json-rpc/schema/methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,27 @@
}
}
},
"VideoLibrary.GetTags": {
"type": "method",
"description": "Retrieve all tags",
"transport": "Response",
"permission": "ReadData",
"params": [
{ "name": "type", "type": "string", "required": true, "enum": [ "movie", "tvshow", "musicvideo" ] },
{ "name": "properties", "$ref": "Library.Fields.Tag" },
{ "name": "limits", "$ref": "List.Limits" },
{ "name": "sort", "$ref": "List.Sort" }
],
"returns": {
"type": "object",
"properties": {
"limits": { "$ref": "List.LimitsReturned", "required": true },
"tags": { "type": "array", "required": true,
"items": { "$ref": "Library.Details.Tag" }
}
}
}
},
"VideoLibrary.SetMovieDetails": {
"type": "method",
"description": "Update the given movie with the given details",
Expand Down
11 changes: 11 additions & 0 deletions xbmc/interfaces/json-rpc/schema/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@
"thumbnail": { "type": "string" }
}
},
"Library.Fields.Tag": {
"extends": "Item.Fields.Base",
"items": { "type": "string", "enum": [ "title" ] }
},
"Library.Details.Tag": {
"extends": "Item.Details.Base",
"properties": {
"tagid": { "$ref": "Library.Id", "required": true },
"title": { "type": "string" }
}
},
"Audio.Fields.Role": {
"extends": "Item.Fields.Base",
"items": { "type": "string", "enum": [ "title" ] }
Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/schema/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.13.2
7.14.0

0 comments on commit 5ac6aab

Please sign in to comment.