Search Top Rated
Run a search from a script with SetQuery
This sample shows how to build a VideoQuery and push it to the user interface with IGUI.SetQuery - the result shows up in the program exactly as if the query had been entered in the search window.
The query here matches all videos with a rating at or above a threshold. Pass the minimum rating (1-5) as the script argument; the default is 4.
using System;
using VideoCataloger;
using VideoCataloger.RemoteCatalogService;
class Script
{
static public async System.Threading.Tasks.Task Run(IScripting scripting, string arguments)
{
IConsole console = scripting.GetConsole();
console.Clear();
int min_rating = 4;
string argument = (arguments ?? "").Trim();
if (argument.Length > 0 && !int.TryParse(argument, out min_rating))
{
console.WriteLine("Pass the minimum rating (1-5) as the script argument.");
return;
}
VideoQuery query = new VideoQuery();
query.Properties = new VideoQueryProperties();
query.Properties.Rating = min_rating;
query.Properties.RatingCompare = ">=";
scripting.GetGUI().SetQuery(query, null); // null scene query - only search videos
console.WriteLine("Showing videos with rating >= " + min_rating + ".");
}
}