Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jsonrpc: add tag support (get, set and filter) for tvshows and musicv…

…ideos
  • Loading branch information...
commit 21ee3916faa2aa7eaa3c40f36594f4a8a31a50d4 1 parent b747d5d
Sascha Montellese Montellese authored
20 xbmc/interfaces/json-rpc/ServiceDescription.h
View
@@ -455,7 +455,7 @@ namespace JSONRPC
"\"imdbnumber\", \"premiered\", \"votes\", \"lastplayed\","
"\"fanart\", \"thumbnail\", \"file\", \"originaltitle\","
"\"sorttitle\", \"episodeguide\", \"season\", \"watchedepisodes\","
- "\"dateadded\"]"
+ "\"dateadded\", \"tag\" ]"
"}"
"}",
"\"Video.Fields.Season\": {"
@@ -483,7 +483,7 @@ namespace JSONRPC
"\"enum\": [ \"title\", \"playcount\", \"runtime\", \"director\","
"\"studio\", \"year\", \"plot\", \"album\", \"artist\","
"\"genre\", \"track\", \"streamdetails\", \"lastplayed\","
- "\"fanart\", \"thumbnail\", \"file\", \"resume\", \"dateadded\" ]"
+ "\"fanart\", \"thumbnail\", \"file\", \"resume\", \"dateadded\", \"tag\" ]"
"}"
"}",
"\"Video.Cast\": {"
@@ -629,7 +629,8 @@ namespace JSONRPC
"\"premiered\": { \"type\": \"string\" },"
"\"votes\": { \"type\": \"string\" },"
"\"episodeguide\": { \"type\": \"string\" },"
- "\"season\": { \"type\": \"integer\" }"
+ "\"season\": { \"type\": \"integer\" },"
+ "\"tag\": { \"$ref\": \"Array.String\" }"
"}"
"}",
"\"Video.Details.Season\": {"
@@ -668,7 +669,8 @@ namespace JSONRPC
"\"album\": { \"type\": \"string\" },"
"\"artist\": { \"$ref\": \"Array.String\" },"
"\"genre\": { \"$ref\": \"Array.String\" },"
- "\"track\": { \"type\": \"integer\" }"
+ "\"track\": { \"type\": \"integer\" },"
+ "\"tag\": { \"$ref\": \"Array.String\" }"
"}"
"}",
"\"Files.Media\": {"
@@ -1382,7 +1384,7 @@ namespace JSONRPC
"\"transport\": \"Response\","
"\"permission\": \"ControlPlayback\","
"\"params\": ["
- "{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true },"
+ "{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true }"
"{ \"name\": \"value\", \"type\": \"string\", \"enum\": [ \"clockwise\", \"counterclockwise\" ], \"default\": \"clockwise\" }"
"],"
"\"returns\": \"string\""
@@ -2116,6 +2118,7 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"year\": { \"type\": \"integer\", \"minimum\": 0, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"actor\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"studio\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"type\": \"object\", \"properties\": { \"tag\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"$ref\": \"List.Filter.TVShows\" }"
"]"
"}"
@@ -2227,6 +2230,7 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"year\": { \"type\": \"integer\", \"minimum\": 0, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"director\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"studio\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"type\": \"object\", \"properties\": { \"tag\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"$ref\": \"List.Filter.MusicVideos\" }"
"]"
"}"
@@ -2391,7 +2395,8 @@ namespace JSONRPC
"{ \"name\": \"sorttitle\", \"$ref\": \"Optional.String\" },"
"{ \"name\": \"episodeguide\", \"$ref\": \"Optional.String\" },"
"{ \"name\": \"thumbnail\", \"$ref\": \"Optional.String\" },"
- "{ \"name\": \"fanart\", \"$ref\": \"Optional.String\" }"
+ "{ \"name\": \"fanart\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"tag\", \"type\": [ \"null\", { \"$ref\": \"Array.String\", \"required\": true } ], \"default\": null }"
"],"
"\"returns\": \"string\""
"}",
@@ -2441,7 +2446,8 @@ namespace JSONRPC
"{ \"name\": \"track\", \"$ref\": \"Optional.Integer\" },"
"{ \"name\": \"lastplayed\", \"$ref\": \"Optional.String\" },"
"{ \"name\": \"thumbnail\", \"$ref\": \"Optional.String\" },"
- "{ \"name\": \"fanart\", \"$ref\": \"Optional.String\" }"
+ "{ \"name\": \"fanart\", \"$ref\": \"Optional.String\" },"
+ "{ \"name\": \"tag\", \"type\": [ \"null\", { \"$ref\": \"Array.String\", \"required\": true } ], \"default\": null }"
"],"
"\"returns\": \"string\""
"}",
6 xbmc/interfaces/json-rpc/VideoLibrary.cpp
View
@@ -170,6 +170,8 @@ JSONRPC_STATUS CVideoLibrary::GetTVShows(const CStdString &method, ITransportLay
videoUrl.AddOption("actor", filter["actor"].asString());
else if (filter.isMember("studio"))
videoUrl.AddOption("studio", filter["studio"].asString());
+ else if (filter.isMember("tag"))
+ videoUrl.AddOption("tag", filter["tag"].asString());
else if (filter.isObject())
{
CStdString xsp;
@@ -187,7 +189,7 @@ JSONRPC_STATUS CVideoLibrary::GetTVShows(const CStdString &method, ITransportLay
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
{
CStdString fieldValue = itr->asString();
- if (fieldValue == "cast")
+ if (fieldValue == "cast" || fieldValue == "tag")
additionalInfo = true;
}
@@ -351,6 +353,8 @@ JSONRPC_STATUS CVideoLibrary::GetMusicVideos(const CStdString &method, ITranspor
videoUrl.AddOption("director", filter["director"].asString());
else if (filter.isMember("studio"))
videoUrl.AddOption("studio", filter["studio"].asString());
+ else if (filter.isMember("tag"))
+ videoUrl.AddOption("tag", filter["tag"].asString());
else if (filter.isObject())
{
CStdString xsp;
8 xbmc/interfaces/json-rpc/methods.json
View
@@ -1051,6 +1051,7 @@
{ "type": "object", "properties": { "year": { "type": "integer", "minimum": 0, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "actor": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "studio": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "type": "object", "properties": { "tag": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "$ref": "List.Filter.TVShows" }
]
}
@@ -1162,6 +1163,7 @@
{ "type": "object", "properties": { "year": { "type": "integer", "minimum": 0, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "director": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "studio": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "type": "object", "properties": { "tag": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "$ref": "List.Filter.MusicVideos" }
]
}
@@ -1326,7 +1328,8 @@
{ "name": "sorttitle", "$ref": "Optional.String" },
{ "name": "episodeguide", "$ref": "Optional.String" },
{ "name": "thumbnail", "$ref": "Optional.String" },
- { "name": "fanart", "$ref": "Optional.String" }
+ { "name": "fanart", "$ref": "Optional.String" },
+ { "name": "tag", "type": [ "null", { "$ref": "Array.String", "required": true } ], "default": null }
],
"returns": "string"
},
@@ -1376,7 +1379,8 @@
{ "name": "track", "$ref": "Optional.Integer" },
{ "name": "lastplayed", "$ref": "Optional.String" },
{ "name": "thumbnail", "$ref": "Optional.String" },
- { "name": "fanart", "$ref": "Optional.String" }
+ { "name": "fanart", "$ref": "Optional.String" },
+ { "name": "tag", "type": [ "null", { "$ref": "Array.String", "required": true } ], "default": null }
],
"returns": "string"
},
10 xbmc/interfaces/json-rpc/types.json
View
@@ -427,7 +427,7 @@
"imdbnumber", "premiered", "votes", "lastplayed",
"fanart", "thumbnail", "file", "originaltitle",
"sorttitle", "episodeguide", "season", "watchedepisodes",
- "dateadded"]
+ "dateadded", "tag" ]
}
},
"Video.Fields.Season": {
@@ -455,7 +455,7 @@
"enum": [ "title", "playcount", "runtime", "director",
"studio", "year", "plot", "album", "artist",
"genre", "track", "streamdetails", "lastplayed",
- "fanart", "thumbnail", "file", "resume", "dateadded" ]
+ "fanart", "thumbnail", "file", "resume", "dateadded", "tag" ]
}
},
"Video.Cast": {
@@ -601,7 +601,8 @@
"premiered": { "type": "string" },
"votes": { "type": "string" },
"episodeguide": { "type": "string" },
- "season": { "type": "integer" }
+ "season": { "type": "integer" },
+ "tag": { "$ref": "Array.String" }
}
},
"Video.Details.Season": {
@@ -640,7 +641,8 @@
"album": { "type": "string" },
"artist": { "$ref": "Array.String" },
"genre": { "$ref": "Array.String" },
- "track": { "type": "integer" }
+ "track": { "type": "integer" },
+ "tag": { "$ref": "Array.String" }
}
},
"Files.Media": {
36 xbmc/video/VideoDatabase.cpp
View
@@ -2077,6 +2077,13 @@ int CVideoDatabase::SetDetailsForTvShow(const CStdString& strPath, const CVideoI
for (i = 0; i < vecStudios.size(); ++i)
AddStudioToTvShow(idTvShow, vecStudios[i]);
+ // add tags...
+ for (unsigned int i = 0; i < details.m_tags.size(); i++)
+ {
+ int idTag = AddTag(details.m_tags[i]);
+ AddTagToItem(idTvShow, idTag, "tvshow");
+ }
+
// add "all seasons" - the rest are added in SetDetailsForEpisode
AddSeason(idTvShow, -1);
@@ -2255,6 +2262,13 @@ int CVideoDatabase::SetDetailsForMusicVideo(const CStdString& strFilenameAndPath
AddStudioToMusicVideo(idMVideo, vecStudios[i]);
}
+ // add tags...
+ for (unsigned int i = 0; i < details.m_tags.size(); i++)
+ {
+ int idTag = AddTag(details.m_tags[i]);
+ AddTagToItem(idMVideo, idTag, "musicvideo");
+ }
+
if (details.HasStreamDetails())
SetStreamDetailsForFileId(details.m_streamDetails, GetFileId(strFilenameAndPath));
@@ -3252,6 +3266,15 @@ CVideoInfoTag CVideoDatabase::GetDetailsForTvShow(const dbiplus::sql_record* con
{
GetCast("tvshow", "idShow", details.m_iDbId, details.m_cast);
+ // get tags
+ CStdString strSQL = PrepareSQL("SELECT tag.strTag FROM tag, taglinks WHERE taglinks.idMedia = %i AND taglinks.media_type = 'tvshow' AND taglinks.idTag = tag.idTag ORDER BY tag.idTag", idTvShow);
+ m_pDS2->query(strSQL.c_str());
+ while (!m_pDS2->eof())
+ {
+ details.m_tags.push_back(m_pDS2->fv("tag.strTag").get_asString());
+ m_pDS2->next();
+ }
+
castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
details.m_strPictureURL.Parse();
}
@@ -3323,10 +3346,10 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record*
CVideoInfoTag details;
unsigned int time = XbmcThreads::SystemClockMillis();
- int idMovie = record->at(0).get_asInt();
+ int idMVideo = record->at(0).get_asInt();
GetDetailsFromDB(record, VIDEODB_ID_MUSICVIDEO_MIN, VIDEODB_ID_MUSICVIDEO_MAX, DbMusicVideoOffsets, details);
- details.m_iDbId = idMovie;
+ details.m_iDbId = idMVideo;
details.m_type = "musicvideo";
details.m_iFileId = record->at(VIDEODB_DETAILS_FILEID).get_asInt();
@@ -3342,6 +3365,15 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record*
movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
+ // get tags
+ CStdString strSQL = PrepareSQL("SELECT tag.strTag FROM tag, taglinks WHERE taglinks.idMedia = %i AND taglinks.media_type = 'musicvideo' AND taglinks.idTag = tag.idTag ORDER BY tag.idTag", idMVideo);
+ m_pDS2->query(strSQL.c_str());
+ while (!m_pDS2->eof())
+ {
+ details.m_tags.push_back(m_pDS2->fv("tag.strTag").get_asString());
+ m_pDS2->next();
+ }
+
details.m_strPictureURL.Parse();
return details;
}
Please sign in to comment.
Something went wrong with that request. Please try again.