private RecordInfo BuildRecordInfoFromKeywords(RecordInfo recordInfo, Tuple <KeywordInfo, int> tuple) { recordInfo.keywordPos = tuple.Item2; //used for sorting the most important shows KeywordInfo keywordInfo = tuple.Item1; recordInfo.preMinutes = keywordInfo.preMinutes; recordInfo.postMinutes = keywordInfo.postMinutes; recordInfo.starredFlag = keywordInfo.starredFlag; recordInfo.emailFlag = keywordInfo.emailFlag; recordInfo.qualityPref = keywordInfo.qualityPref; recordInfo.langPref = keywordInfo.langPref; recordInfo.channelPref = keywordInfo.channelPref; return(recordInfo); }
// // This is a key member function. This and 'CaptureStream' do the bulk of the work // // As such, I'll document this a bit more than usual so when I forget (tomorrow) I can read and remember some... // public List <RecordInfo> BuildRecordSchedule() { //Refresh keywords // //Reads keywords from the keywords.json file. This is data used to determine which entries in the schedule //we are interested in recording/capturing Keywords keywords = new Keywords(configuration); //Refresh schedule from website // // This goes and grabs the online .json file which is the current schedule from Live247 // This list is *all* the shows currently posted. Usually, live247 only posts a day or two at a time. schedule.LoadSchedule(configuration["debug"]).Wait(); List <ScheduleShow> scheduleShowList = schedule.GetScheduledShows(); //Go through the shows and load up recordings if there's a match // //This loop compares keywords and schedule entires, when there's a match, it //adds creates a RecordInfo istance and adds it to a master Dictionary //of shows we thing we care about. Later we'll determine which ones we'll actually capture. foreach (ScheduleShow scheduleShow in scheduleShowList) { //Find any shows that match Tuple <KeywordInfo, int> tuple = keywords.FindMatch(scheduleShow.name); if (tuple != null) { KeywordInfo keywordInfo = tuple.Item1; //Build record info if already exists, otherwise, create new RecordInfo recordInfo = GetRecordInfo(BuildRecordInfoKeyValue(scheduleShow)); //Fill out the recording info recordInfo.channels.AddUpdateChannel(scheduleShow.channel, scheduleShow.quality, scheduleShow.language); recordInfo.id = scheduleShow.id; recordInfo.description = scheduleShow.name; recordInfo.strStartDT = scheduleShow.time; //recordInfo.strStartDT = DateTime.Now.AddHours(4).ToString(); recordInfo.strEndDT = scheduleShow.end_time; recordInfo.strDuration = scheduleShow.runtime; //recordInfo.strDuration = "1"; recordInfo.strDTOffset = configuration["schedTimeOffset"]; recordInfo.preMinutes = keywordInfo.preMinutes; recordInfo.postMinutes = keywordInfo.postMinutes; recordInfo.starredFlag = keywordInfo.starredFlag; recordInfo.emailFlag = keywordInfo.emailFlag; recordInfo.qualityPref = keywordInfo.qualityPref; recordInfo.categoryPref = keywordInfo.categoryPref; recordInfo.langPref = keywordInfo.langPref; recordInfo.channelPref = keywordInfo.channelPref; recordInfo.category = scheduleShow.category; recordInfo.keywordPos = tuple.Item2; //used for sorting the most important shows //Clean up description, and then use as filename recordInfo.fileName = scheduleShow.name.Replace(' ', '_'); string myChars = @"|'/\ ,<>#@!+&^*()~`;"; string invalidChars = myChars + new string(Path.GetInvalidFileNameChars()); foreach (char c in invalidChars) { recordInfo.fileName = recordInfo.fileName.Replace(c.ToString(), ""); } //If starred, add designator to filename if (recordInfo.starredFlag) { recordInfo.fileName = "+_" + recordInfo.fileName; } //Update or add AddUpdateRecordInfo(BuildRecordInfoKeyValue(recordInfo), recordInfo); } } //Return shows that should actually be queued (omitted those already done, too far in the future, etc...) // //This is an important call. Please see remarks in this member function for more info. return(GetShowsToQueue()); }