James, i will post the function here, its big but you will understand, but i will make the request in one line and post later.
I made this function to request tvshows. Its big because i am manipulating 3 filters and 2 operators. this function first analyze the 2º filter, the analyze the 2º, use the operator to determine if its true or not, and then compare the result with the first filter. I will try to explain this better later.
I will mount the request in a simple line with some examples, i just cant make this right now, sorry.
See the function:
self.getTvshowFilter2 = function(type,linkOperator1,linkOperator2,baseJoin,sortorder,sortmethod,field1,operator1,value1,field2,operator2,value2,field3,operator3,
value3,limits){
var linkoperator1 = linkOperator1;
var linkoperator2 = linkOperator2;
if (limits) {
var limits = parseInt(limits);
var params = {
sort: {"order": sortorder, "method": sortmethod},
properties: ["title","art","episode","watchedepisodes","year","imdbnumber","playcount","plot"],
filter: {},
limits: {"end": limits}
};
} else {
var params = {
sort: {"order": sortorder, "method": sortmethod},
properties: ["title","art","episode","watchedepisodes","year","imdbnumber","playcount","plot"],
filter: {}
};
}
if (type=="1"){
params.filter = {field: field1, operator: operator1, value: value1};
}
if (type == "2"){
params.filter[linkoperator1] = [
{field: field1, operator: operator1, value: value1},
{field: field2, operator: operator2, value: value2}
];
} else if(type == "3"){
var filteroperator2 = {};
filteroperator2[linkoperator2] = [
{field: field2, operator: operator2, value: value2},
{field: field3, operator: operator3, value: value3},
];
params.filter[linkoperator1] =[
filteroperator2,
{field: field1, operator: operator1, value: value1}
]
}
self.rpc("VideoLibrary.GetTVShows", params, function(data) {
// CF.logObject(data);
CF.listRemove("l"+baseJoin);
var arrayTvShowFilter = [];
for (i=0;i<data.result.limits.end;i++){
var tvshowid = data.result.tvshows[i].tvshowid;
var showtitle = decode_utf8(data.result.tvshows[i].title);
var plot = decode_utf8(data.result.tvshows[i].plot);
var banner = self.URL + "vfs/" + data.result.tvshows[i].art.banner;
var episode = data.result.tvshows[i].episode;
var watchedepisodes = data.result.tvshows[i].watchedepisodes;
var unwatched = episode - watchedepisodes;
var unwatched = "Não Assistidos: "+ unwatched;
var playcount = data.result.tvshows[i].playcount;
var playcount = (playcount > 0) ? 1:0;
var year = "("+data.result.tvshows[i].year+")";
var imdbnumber = data.result.tvshows[i].imdbnumber;
arrayTvShowFilter.push({
s21 : tvshowid,
s22 : showtitle,
s23 : banner,
s24 : year,
s25 : unwatched,
d21: {
tokens: {
"[tvshowid]": tvshowid,
"[imdbnumber]": imdbnumber,
"[plot]": plot,
}
},
d22: playcount
});
}
CF.listAdd("l"+baseJoin,arrayTvShowFilter)
if (baseJoin == XBMCMacMini.joinTvShowWallTopList){
self.arrayTvShowWall = [];
self.arrayTvShowWall = arrayTvShowFilter;
self.buildTvShowWall(XBMCMacMini.joinTvShowWall,2);
}
})
}