Example #1
0
        public static Schedule CreateRecordOnceSchedule(ChannelType channelType, Guid channelId, string title, string subTitle, string episodeNumber, DateTime startTime)
        {
            Schedule schedule = Proxies.SchedulerService.CreateNewSchedule(channelType, ScheduleType.Recording).Result;

            schedule.Name = GuideProgram.CreateProgramTitle(title, subTitle, episodeNumber);
            schedule.Rules.Add(ScheduleRuleType.Channels, channelId);
            schedule.Rules.Add(ScheduleRuleType.OnDate, startTime.Date);
            schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(startTime.TimeOfDay));
            schedule.Rules.Add(ScheduleRuleType.TitleEquals, title);
            if (!String.IsNullOrEmpty(subTitle))
            {
                schedule.Rules.Add(ScheduleRuleType.SubTitleEquals, subTitle);
            }
            else if (!String.IsNullOrEmpty(episodeNumber))
            {
                schedule.Rules.Add(ScheduleRuleType.EpisodeNumberEquals, episodeNumber);
            }
            return(schedule);
        }
Example #2
0
        private void SetLabels()
        {
            UpcomingRecording[]             upcomingRecordings       = ControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true);
            UpcomingGuideProgram[]          upcomingAlerts           = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Alert, true);
            UpcomingGuideProgram[]          upcomingSuggestions      = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Suggestion, true);
            UpcomingGuideProgramsDictionary AllUpcomingGuidePrograms = new UpcomingGuideProgramsDictionary(upcomingRecordings, upcomingAlerts, upcomingSuggestions);

            foreach (GUIListItem item in _viewsList.ListItems)
            {
                if (item.Label != _parentDirectoryLabel)
                {
                    UpcomingProgram program = item.TVTag as UpcomingProgram;
                    if (program != null)
                    {
                        if (!item.IsFolder)
                        {
                            item.PinImage = null;
                            Guid upcomingProgramId = program.UpcomingProgramId;
                            if (AllUpcomingGuidePrograms.ContainsKey(upcomingProgramId))
                            {
                                GuideUpcomingProgram programInfo = AllUpcomingGuidePrograms[upcomingProgramId];
                                item.PinImage = Utility.GetIconImageFileName(programInfo.Type, programInfo.IsPartOfSeries,
                                                                             programInfo.CancellationReason, programInfo.UpcomingRecording);
                            }

                            string title = GuideProgram.CreateProgramTitle(program.Title, program.SubTitle, program.EpisodeNumberDisplay);
                            item.Label = title;
                            string logoImagePath = Utility.GetLogoImage(program.Channel, _tvSchedulerAgent);
                            if (logoImagePath == null ||
                                !System.IO.File.Exists(logoImagePath))
                            {
                                item.Label    = String.Format("[{0}] {1}", program.Channel.DisplayName, title);
                                logoImagePath = "defaultVideoBig.png";
                            }

                            item.ThumbnailImage = logoImagePath;
                            item.IconImageBig   = logoImagePath;
                            item.IconImage      = logoImagePath;

                            item.Label2 = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(program.StartTime),
                                                        program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                        program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                            if (_currentSortMethod == SortMethod.Channel)
                            {
                                item.Label3 = program.Channel.DisplayName;
                            }
                            else
                            {
                                item.Label3 = program.Category;
                            }
                        }
                        else
                        {
                            Utils.SetDefaultIcons(item);
                            item.Label = program.Title;
                        }
                    }
                }
            }
            AllUpcomingGuidePrograms.Clear();
            AllUpcomingGuidePrograms = null;
        }
Example #3
0
        private IMBotMessage DoRecordCommand(IMBotConversation conversation, IList <string> arguments)
        {
            if (arguments.Count == 0)
            {
                return(new IMBotMessage("Program number missing.", IMBotMessage.ErrorColor));
            }

            RepeatingType repeatingType = RepeatingType.None;

            if (arguments.Count > 1)
            {
                switch (arguments[1].ToLowerInvariant())
                {
                case "once":
                case "o": repeatingType = RepeatingType.Once; break;

                case "daily":
                case "d": repeatingType = RepeatingType.Daily; break;

                case "weekly":
                case "w": repeatingType = RepeatingType.Weekly; break;

                case "workingdays":
                case "wd": repeatingType = RepeatingType.WorkingDays; break;

                case "weekends":
                case "we": repeatingType = RepeatingType.Weekends; break;

                case "anytime":
                case "a": repeatingType = RepeatingType.AnyTime; break;
                }
            }

            int programNumber;

            if (repeatingType == RepeatingType.None ||
                !int.TryParse(arguments[0], out programNumber))
            {
                return(new IMBotMessage("Please specify program number and once, daily, weekly, workingdays, weekends or anytime.", IMBotMessage.ErrorColor));
            }

            Session.Programs sessionPrograms = null;
            if (conversation.Session.ContainsKey(SessionKey.Programs))
            {
                sessionPrograms = conversation.Session[SessionKey.Programs] as Session.Programs;
            }

            IProgramSummary program = null;
            Channel         channel = null;

            if (sessionPrograms != null)
            {
                program = sessionPrograms.GetProgramAt(programNumber, out channel);
                if (program == null)
                {
                    return(new IMBotMessage("Bad program number.", IMBotMessage.ErrorColor));
                }
            }
            else
            {
                return(new IMBotMessage("No programs.", IMBotMessage.ErrorColor));
            }

            Schedule schedule = Proxies.SchedulerService.CreateNewSchedule(GetChannelType(conversation), ScheduleType.Recording).Result;

            bool   newEpisodesOnly = arguments.Count > 2 && arguments[2].Equals("new", StringComparison.CurrentCultureIgnoreCase);
            string repeatingText   = String.Empty;

            if (repeatingType == RepeatingType.Once)
            {
                schedule.Name = GuideProgram.CreateProgramTitle(program.Title, program.SubTitle, program.EpisodeNumberDisplay);
                schedule.Rules.Add(ScheduleRuleType.OnDate, program.StartTime.Date);
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                if (!String.IsNullOrEmpty(program.SubTitle))
                {
                    schedule.Rules.Add(ScheduleRuleType.SubTitleEquals, program.SubTitle);
                }
                else if (!String.IsNullOrEmpty(program.EpisodeNumberDisplay))
                {
                    schedule.Rules.Add(ScheduleRuleType.EpisodeNumberEquals, program.EpisodeNumberDisplay);
                }
                newEpisodesOnly = false;
            }
            else if (repeatingType == RepeatingType.AnyTime)
            {
                schedule.Name = program.Title + " (Any Time)";
                repeatingText = " any time";
            }
            else if (repeatingType == RepeatingType.Weekly)
            {
                schedule.Name = program.Title + " (Weekly)";
                schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, GetDaysOfWeek(program.StartTime));
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                repeatingText = " weekly";
            }
            else if (repeatingType == RepeatingType.WorkingDays)
            {
                schedule.Name = program.Title + " (Mon-Fri)";
                schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, ScheduleDaysOfWeek.WorkingDays);
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                repeatingText = " Mon-Fri";
            }
            else if (repeatingType == RepeatingType.Weekends)
            {
                schedule.Name = program.Title + " (Sat-Sun)";
                schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, ScheduleDaysOfWeek.Weekends);
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                repeatingText = " Sat-Sun";
            }
            else if (repeatingType == RepeatingType.Weekly)
            {
                schedule.Name = program.Title + " (Weekly)";
                schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, GetDaysOfWeek(program.StartTime));
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                repeatingText = " weekly";
            }
            else
            {
                schedule.Name = program.Title + " (Daily)";
                schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
                repeatingText = " daily";
            }
            if (newEpisodesOnly)
            {
                schedule.Rules.Add(ScheduleRuleType.NewEpisodesOnly, true);
            }
            schedule.Rules.Add(ScheduleRuleType.Channels, channel.ChannelId);
            schedule.Rules.Add(ScheduleRuleType.TitleEquals, program.Title);
            Proxies.SchedulerService.SaveSchedule(schedule).Wait();

            StringBuilder replyText = new StringBuilder();

            replyText.Append("Created schedule to record ");
            Utility.AppendProgramDetails(replyText, channel, program);
            replyText.Append(repeatingText);
            if (newEpisodesOnly)
            {
                replyText.Append(" (record episodes once)");
            }
            replyText.Append(".");

            return(new IMBotMessage(replyText.ToString()));
        }