2004-11-14, 11:37 PM
Here is some C# source code for searching for an Episode by Keyword. This only checks the title, and the function can be modified for anybody's use. Since I wanted to learn C# (amazing how much like Java it is. ) and GBPVR was missing a more robust search method to find episodes, I figured I'd give this a whirl. Took about a half hour to get working, but this will take a keyword, and search all channels from the current date and time to an ending date 30 days out. It'll return all episodes that have that keyword in the title. I believe Jorm is planning on implementing something like this for the UI, I may try and get this implemented for the Web Interface as well. I don't plan to use the UI too much, just the recording engine.
Anyway, here is the function, feel free to modify it and use it as you wish in your own plugins.
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
private static void SearchForEpisodeByTitle() {
ScheduleHelper scheduleHelper = ScheduleHelper.getInstance();
// Search for an episode listing, set the start time and the end time
DateTime startTime = DateTime.Now;
DateTime endTime = startTime.AddDays((double) 30);
String searchFor = "Apprentice";
IList allChannels = scheduleHelper.GetListingsForTimePeriod(startTime, endTime);
foreach (Channel channel in allChannels) {
foreach (Programme program in channel.getProgrammeList()) {
String findString = program.getTitle().ToUpper();
if (findString.IndexOf(searchFor.ToUpper(), 0) >= 0) {
Console.WriteLine("Found: " + searchFor);
Console.WriteLine("Title: " + program.getTitle());
Console.WriteLine("Channel: " + channel.channelName);
Console.WriteLine("Start Time: " + program.getStartTime().ToLongDateString() + " " + program.getStartTime().ToLongTimeString());
Console.WriteLine("End Time: " + program.getEndTime().ToLongDateString() + " " + program.getStartTime().ToLongTimeString());
}
}
}
}
[/QUOTE]
Anyway, here is the function, feel free to modify it and use it as you wish in your own plugins.
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
private static void SearchForEpisodeByTitle() {
ScheduleHelper scheduleHelper = ScheduleHelper.getInstance();
// Search for an episode listing, set the start time and the end time
DateTime startTime = DateTime.Now;
DateTime endTime = startTime.AddDays((double) 30);
String searchFor = "Apprentice";
IList allChannels = scheduleHelper.GetListingsForTimePeriod(startTime, endTime);
foreach (Channel channel in allChannels) {
foreach (Programme program in channel.getProgrammeList()) {
String findString = program.getTitle().ToUpper();
if (findString.IndexOf(searchFor.ToUpper(), 0) >= 0) {
Console.WriteLine("Found: " + searchFor);
Console.WriteLine("Title: " + program.getTitle());
Console.WriteLine("Channel: " + channel.channelName);
Console.WriteLine("Start Time: " + program.getStartTime().ToLongDateString() + " " + program.getStartTime().ToLongTimeString());
Console.WriteLine("End Time: " + program.getEndTime().ToLongDateString() + " " + program.getStartTime().ToLongTimeString());
}
}
}
}
[/QUOTE]