Esempio n. 1
0
        //Let's load the record info object from the show found in the schedule
        public RecordInfo BuildRecordInfoFromShedule(RecordInfo recordInfo, ScheduleShow scheduleShow)
        {
            //Fill out the recording info
            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.category    = scheduleShow.category;
            //recordInfo.strDuration = "1";
            recordInfo.strDTOffset = configuration["schedTimeOffset"];

            //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;
            }

            return(recordInfo);
        }
        //Given a show name, see if there's a match in any of the keywords
        public Tuple <KeywordInfo, int> FindMatch(ScheduleShow scheduleShow)
        {
            //Go through each keyword section, seeing if there's a match for the show
            KeyValuePair <string, KeywordInfo>[] kvpArray = keywordDict.ToArray();
            for (int kvpIdx = 0; kvpIdx < kvpArray.Length; kvpIdx++)
            {
                //Loop through all keyword rows checking for a match
                bool showMatched = CheckForMatchHelper(kvpArray[kvpIdx].Value.keywords, scheduleShow.name);

                //Make sure categories match (if empty, then no-op)
                if (showMatched)
                {
                    List <string> rows = kvpArray[kvpIdx].Value.categories;
                    if (rows != null && rows.Count > 0)
                    {
                        showMatched = CheckForMatchHelper(rows, scheduleShow.category);
                    }
                }

                //Look for exclusions to verify match
                if (showMatched)
                {
                    bool          excludeMatched = false;
                    List <string> rows           = kvpArray[kvpIdx].Value.exclude;
                    if (rows != null && rows.Count > 0)
                    {
                        excludeMatched = CheckForMatchHelper(rows, scheduleShow.name);
                    }

                    //If we're still good, return the match
                    if (!excludeMatched)
                    {
                        return(new Tuple <KeywordInfo, int>(kvpArray[kvpIdx].Value, kvpIdx));
                    }
                }
            }

            return(null);
        }
Esempio n. 3
0
 public string BuildRecordInfoKeyValue(ScheduleShow scheduleShow)
 {
     return(scheduleShow.time + scheduleShow.name);
 }