Permalink
Browse files

jsonrpc: add basic XSP-based filtering to (Audio|Video)Library.Get(Mo…

…vies|TVShows|Episodes|MusicVideos|Artists|Albums|Songs)
  • Loading branch information...
1 parent a1f8346 commit 96ba3fdf456ff70c759145d5e081f817ca733598 @Montellese committed Aug 7, 2012
View
48 xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -50,14 +50,22 @@ JSONRPC_STATUS CAudioLibrary::GetArtists(const CStdString &method, ITransportLay
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("albumid"))
+ else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
- if (filter.isMember("album"))
+ else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
- if (filter.isMember("songid"))
+ else if (filter.isMember("songid"))
songID = (int)filter["songid"].asInteger();
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("artists", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
bool albumArtistsOnly = !g_guiSettings.GetBool("musiclibrary.showcompilationartists");
if (parameterObject["albumartistsonly"].isBoolean())
@@ -126,12 +134,20 @@ JSONRPC_STATUS CAudioLibrary::GetAlbums(const CStdString &method, ITransportLaye
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
- if (filter.isMember("artist"))
+ else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
- if (filter.isMember("genreid"))
+ else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("albums", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
@@ -185,16 +201,24 @@ JSONRPC_STATUS CAudioLibrary::GetSongs(const CStdString &method, ITransportLayer
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
- if (filter.isMember("artist"))
+ else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
- if (filter.isMember("genreid"))
+ else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("albumid"))
+ else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
- if (filter.isMember("album"))
+ else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("songs", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
View
34 xbmc/interfaces/json-rpc/JSONRPC.cpp
@@ -25,6 +25,7 @@
#include "ServiceDescription.h"
#include "input/ButtonTranslator.h"
#include "interfaces/AnnouncementManager.h"
+#include "playlists/SmartPlayList.h"
#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "utils/Variant.h"
@@ -45,6 +46,39 @@ void CJSONRPC::Initialize()
CButtonTranslator::GetActions(inputActions);
CJSONServiceDescription::AddEnum("Input.Action", inputActions);
+ // filter-related enums
+ vector<string> smartplaylistList;
+ CSmartPlaylist::GetAvailableOperators(smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Operators", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("movies", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Movies", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("tvshows", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.TVShows", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("episodes", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Episodes", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("musicvideos", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.MusicVideos", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("artists", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Artists", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("albums", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Albums", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("songs", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Songs", smartplaylistList);
+
unsigned int size = sizeof(JSONRPC_SERVICE_TYPES) / sizeof(char*);
for (unsigned int index = 0; index < size; index++)
View
14 xbmc/interfaces/json-rpc/JSONUtils.h
@@ -25,6 +25,7 @@
#include "JSONRPCUtils.h"
#include "interfaces/IAnnouncer.h"
+#include "playlists/SmartPlayList.h"
#include "utils/JSONVariantWriter.h"
#include "utils/JSONVariantParser.h"
@@ -395,5 +396,18 @@ namespace JSONRPC
for (CVariant::const_iterator_array it = jsonStringArray.begin_array(); it != jsonStringArray.end_array(); it++)
stringArray.push_back(it->asString());
}
+
+ static bool GetXspFiltering(const CStdString &type, const CVariant &filter, CStdString &xsp)
+ {
+ if (type.empty() || !filter.isObject())
+ return false;
+
+ CVariant xspObj(CVariant::VariantTypeObject);
+ xspObj["type"] = type;
+ xspObj["rules"] = filter;
+
+ CSmartPlaylist playlist;
+ return playlist.Load(xspObj) && playlist.SaveAsJson(xsp, false);
+ }
};
}
View
173 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -710,6 +710,158 @@ namespace JSONRPC
"},"
"\"additionalProperties\": false"
"}",
+ "\"List.Filter.Rule\": {"
+ "\"type\": \"object\","
+ "\"properties\": {"
+ "\"operator\": { \"$ref\": \"List.Filter.Operators\", \"required\": true },"
+ "\"value\": {"
+ "\"type\": ["
+ "{ \"type\": \"string\", \"required\": true },"
+ "{ \"type\": \"array\", \"items\": { \"type\": \"string\" }, \"required\": true }"
+ "], \"required\": true"
+ "}"
+ "}"
+ "}",
+ "\"List.Filter.Rule.Movies\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.Movies\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.TVShows\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.TVShows\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.Episodes\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.Episodes\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.MusicVideos\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.MusicVideos\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.Artists\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.Artists\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.Albums\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.Albums\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Rule.Songs\": {"
+ "\"extends\": \"List.Filter.Rule\","
+ "\"properties\": {"
+ "\"field\": { \"$ref\": \"List.Filter.Fields.Songs\", \"required\": true }"
+ "}"
+ "}",
+ "\"List.Filter.Movies\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Movies\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Movies\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.TVShows\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.TVShows\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.TVShows\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.Episodes\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Episodes\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Episodes\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.MusicVideos\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.MusicVideos\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.MusicVideos\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.Artists\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Artists\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Artists\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.Albums\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Albums\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Albums\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
+ "\"List.Filter.Songs\": {"
+ "\"type\": ["
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"and\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Songs\" }, \"required\": true }"
+ "}"
+ "},"
+ "{ \"type\": \"object\","
+ "\"properties\": {"
+ "\"or\": { \"type\": \"array\", \"items\": { \"$ref\": \"List.Filter.Rule.Songs\" }, \"required\": true }"
+ "}"
+ "}"
+ "]"
+ "}",
"\"List.Fields.All\": {"
"\"extends\": \"Item.Fields.Base\","
"\"items\": { \"type\": \"string\","
@@ -1479,7 +1631,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"genre\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"albumid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"album\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
- "{ \"type\": \"object\", \"properties\": { \"songid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false }"
+ "{ \"type\": \"object\", \"properties\": { \"songid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.Artists\" }"
"]"
"}"
"],"
@@ -1522,7 +1675,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"genreid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"genre\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"artistid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
- "{ \"type\": \"object\", \"properties\": { \"artist\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false }"
+ "{ \"type\": \"object\", \"properties\": { \"artist\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.Albums\" }"
"]"
"}"
"],"
@@ -1567,7 +1721,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"artistid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"artist\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"albumid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
- "{ \"type\": \"object\", \"properties\": { \"album\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false }"
+ "{ \"type\": \"object\", \"properties\": { \"album\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.Songs\" }"
"]"
"}"
"],"
@@ -1825,7 +1980,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"country\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"setid\": { \"$ref\": \"Library.Id\", \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"set\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
- "{ \"type\": \"object\", \"properties\": { \"tag\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false }"
+ "{ \"type\": \"object\", \"properties\": { \"tag\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.Movies\" }"
"]"
"}"
"],"
@@ -1910,7 +2066,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"genre\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"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\": { \"studio\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.TVShows\" }"
"]"
"}"
"],"
@@ -1975,7 +2132,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"genre\": { \"type\": \"string\", \"minLength\": 1, \"required\": true, \"description\": \"Requires tvshowid to be set\" } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"year\": { \"type\": \"integer\", \"minimum\": 0, \"required\": true } }, \"additionalProperties\": false },"
"{ \"type\": \"object\", \"properties\": { \"actor\": { \"type\": \"string\", \"minLength\": 1, \"required\": true, \"description\": \"Requires tvshowid to be set\" } }, \"additionalProperties\": false },"
- "{ \"type\": \"object\", \"properties\": { \"director\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false }"
+ "{ \"type\": \"object\", \"properties\": { \"director\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.Episodes\" }"
"]"
"}"
"],"
@@ -2019,7 +2177,8 @@ namespace JSONRPC
"{ \"type\": \"object\", \"properties\": { \"genre\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
"{ \"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\": { \"studio\": { \"type\": \"string\", \"minLength\": 1, \"required\": true } }, \"additionalProperties\": false },"
+ "{ \"$ref\": \"List.Filter.MusicVideos\" }"
"]"
"}"
"],"
View
76 xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -44,24 +44,32 @@ JSONRPC_STATUS CVideoLibrary::GetMovies(const CStdString &method, ITransportLaye
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
videoUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("year"))
+ else if (filter.isMember("year"))
year = (int)filter["year"].asInteger();
- if (filter.isMember("actor"))
+ else if (filter.isMember("actor"))
videoUrl.AddOption("actor", filter["actor"].asString());
- if (filter.isMember("director"))
+ else if (filter.isMember("director"))
videoUrl.AddOption("director", filter["director"].asString());
- if (filter.isMember("studio"))
+ else if (filter.isMember("studio"))
videoUrl.AddOption("studio", filter["studio"].asString());
- if (filter.isMember("country"))
+ else if (filter.isMember("country"))
videoUrl.AddOption("country", filter["country"].asString());
- if (filter.isMember("setid"))
+ else if (filter.isMember("setid"))
setID = (int)filter["setid"].asInteger();
- if (filter.isMember("set"))
+ else if (filter.isMember("set"))
videoUrl.AddOption("set", filter["set"].asString());
- if (filter.isMember("tag"))
+ else if (filter.isMember("tag"))
videoUrl.AddOption("tag", filter["tag"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("movies", filter, xsp))
+ return InvalidParams;
+
+ videoUrl.AddOption("xsp", xsp);
+ }
// setID must not be -1 otherwise GetMoviesNav() will return sets
if (setID < 0)
@@ -154,14 +162,22 @@ JSONRPC_STATUS CVideoLibrary::GetTVShows(const CStdString &method, ITransportLay
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
videoUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("year"))
+ else if (filter.isMember("year"))
year = (int)filter["year"].asInteger();
- if (filter.isMember("actor"))
+ else if (filter.isMember("actor"))
videoUrl.AddOption("actor", filter["actor"].asString());
- if (filter.isMember("studio"))
+ else if (filter.isMember("studio"))
videoUrl.AddOption("studio", filter["studio"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("tvshows", filter, xsp))
+ return InvalidParams;
+
+ videoUrl.AddOption("xsp", xsp);
+ }
CFileItemList items;
if (!videodatabase.GetTvShowsNav(videoUrl.ToString(), items, genreID, year, -1, -1, -1, sorting))
@@ -246,14 +262,22 @@ JSONRPC_STATUS CVideoLibrary::GetEpisodes(const CStdString &method, ITransportLa
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
videoUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("year"))
+ else if (filter.isMember("year"))
year = (int)filter["year"].asInteger();
- if (filter.isMember("actor"))
+ else if (filter.isMember("actor"))
videoUrl.AddOption("actor", filter["actor"].asString());
- if (filter.isMember("director"))
+ else if (filter.isMember("director"))
videoUrl.AddOption("director", filter["director"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("episodes", filter, xsp))
+ return InvalidParams;
+
+ videoUrl.AddOption("xsp", xsp);
+ }
if (tvshowID <= 0 && (genreID > 0 || filter.isMember("actor")))
return InvalidParams;
@@ -317,16 +341,24 @@ JSONRPC_STATUS CVideoLibrary::GetMusicVideos(const CStdString &method, ITranspor
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artist"))
videoUrl.AddOption("artist", filter["artist"].asString());
- if (filter.isMember("genreid"))
+ else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
videoUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("year"))
+ else if (filter.isMember("year"))
year = (int)filter["year"].asInteger();
- if (filter.isMember("director"))
+ else if (filter.isMember("director"))
videoUrl.AddOption("director", filter["director"].asString());
- if (filter.isMember("studio"))
+ else if (filter.isMember("studio"))
videoUrl.AddOption("studio", filter["studio"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("musicvideos", filter, xsp))
+ return InvalidParams;
+
+ videoUrl.AddOption("xsp", xsp);
+ }
CFileItemList items;
if (!videodatabase.GetMusicVideosNav(videoUrl.ToString(), items, genreID, year, -1, -1, -1, -1, sorting))
View
21 xbmc/interfaces/json-rpc/methods.json
@@ -615,7 +615,8 @@
{ "type": "object", "properties": { "genre": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "albumid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "album": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
- { "type": "object", "properties": { "songid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false }
+ { "type": "object", "properties": { "songid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.Artists" }
]
}
],
@@ -658,7 +659,8 @@
{ "type": "object", "properties": { "genreid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "genre": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "artistid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
- { "type": "object", "properties": { "artist": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false }
+ { "type": "object", "properties": { "artist": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.Albums" }
]
}
],
@@ -703,7 +705,8 @@
{ "type": "object", "properties": { "artistid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "artist": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "albumid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
- { "type": "object", "properties": { "album": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false }
+ { "type": "object", "properties": { "album": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.Songs" }
]
}
],
@@ -961,7 +964,8 @@
{ "type": "object", "properties": { "country": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "setid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "set": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
- { "type": "object", "properties": { "tag": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false }
+ { "type": "object", "properties": { "tag": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.Movies" }
]
}
],
@@ -1046,7 +1050,8 @@
{ "type": "object", "properties": { "genre": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "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": { "studio": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.TVShows" }
]
}
],
@@ -1111,7 +1116,8 @@
{ "type": "object", "properties": { "genre": { "type": "string", "minLength": 1, "required": true, "description": "Requires tvshowid to be set" } }, "additionalProperties": false },
{ "type": "object", "properties": { "year": { "type": "integer", "minimum": 0, "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "actor": { "type": "string", "minLength": 1, "required": true, "description": "Requires tvshowid to be set" } }, "additionalProperties": false },
- { "type": "object", "properties": { "director": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false }
+ { "type": "object", "properties": { "director": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.Episodes" }
]
}
],
@@ -1155,7 +1161,8 @@
{ "type": "object", "properties": { "genre": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
{ "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": { "studio": { "type": "string", "minLength": 1, "required": true } }, "additionalProperties": false },
+ { "$ref": "List.Filter.MusicVideos" }
]
}
],
View
152 xbmc/interfaces/json-rpc/types.json
@@ -682,6 +682,158 @@
},
"additionalProperties": false
},
+ "List.Filter.Rule": {
+ "type": "object",
+ "properties": {
+ "operator": { "$ref": "List.Filter.Operators", "required": true },
+ "value": {
+ "type": [
+ { "type": "string", "required": true },
+ { "type": "array", "items": { "type": "string" }, "required": true }
+ ], "required": true
+ }
+ }
+ },
+ "List.Filter.Rule.Movies": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.Movies", "required": true }
+ }
+ },
+ "List.Filter.Rule.TVShows": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.TVShows", "required": true }
+ }
+ },
+ "List.Filter.Rule.Episodes": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.Episodes", "required": true }
+ }
+ },
+ "List.Filter.Rule.MusicVideos": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.MusicVideos", "required": true }
+ }
+ },
+ "List.Filter.Rule.Artists": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.Artists", "required": true }
+ }
+ },
+ "List.Filter.Rule.Albums": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.Albums", "required": true }
+ }
+ },
+ "List.Filter.Rule.Songs": {
+ "extends": "List.Filter.Rule",
+ "properties": {
+ "field": { "$ref": "List.Filter.Fields.Songs", "required": true }
+ }
+ },
+ "List.Filter.Movies": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.Movies" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.Movies" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.TVShows": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.TVShows" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.TVShows" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.Episodes": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.Episodes" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.Episodes" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.MusicVideos": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.MusicVideos" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.MusicVideos" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.Artists": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.Artists" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.Artists" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.Albums": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.Albums" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.Albums" }, "required": true }
+ }
+ }
+ ]
+ },
+ "List.Filter.Songs": {
+ "type": [
+ { "type": "object",
+ "properties": {
+ "and": { "type": "array", "items": { "$ref": "List.Filter.Rule.Songs" }, "required": true }
+ }
+ },
+ { "type": "object",
+ "properties": {
+ "or": { "type": "array", "items": { "$ref": "List.Filter.Rule.Songs" }, "required": true }
+ }
+ }
+ ]
+ },
"List.Fields.All": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
View
19 xbmc/playlists/SmartPlayList.cpp
@@ -1371,3 +1371,22 @@ CStdString CSmartPlaylist::GetSaveLocation() const
// all others are video
return "video";
}
+
+void CSmartPlaylist::GetAvailableFields(const std::string &type, std::vector<std::string> &fieldList)
+{
+ vector<Field> typeFields = CSmartPlaylistRule::GetFields(type);
+ for (vector<Field>::const_iterator field = typeFields.begin(); field != typeFields.end(); field++)
+ {
+ for (unsigned int i = 0; i < NUM_FIELDS; i++)
+ {
+ if (*field == fields[i].field)
+ fieldList.push_back(fields[i].string);
+ }
+ }
+}
+
+void CSmartPlaylist::GetAvailableOperators(std::vector<std::string> &operatorList)
+{
+ for (unsigned int index = 0; index < NUM_OPERATORS; index++)
+ operatorList.push_back(operators[index].string);
+}
View
3 xbmc/playlists/SmartPlayList.h
@@ -189,6 +189,9 @@ class CSmartPlaylist
CStdString GetSaveLocation() const;
+ static void GetAvailableFields(const std::string &type, std::vector<std::string> &fieldList);
+ static void GetAvailableOperators(std::vector<std::string> &operatorList);
+
private:
friend class CGUIDialogSmartPlaylistEditor;

0 comments on commit 96ba3fd

Please sign in to comment.