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 30, 2015
1 parent 5506bb3 commit a1dbcd1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,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 @@ -472,6 +472,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 (unsigned int i = 0; i < static_cast<unsigned int>(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 @@ -50,6 +50,7 @@ namespace JSONRPC
static JSONRPC_STATUS GetRecentlyAddedMusicVideos(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 @@ -1317,6 +1317,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 @@ -390,6 +390,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.Artist": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
Expand Down

0 comments on commit a1dbcd1

Please sign in to comment.