示例#1
0
        private void events_OnTvServerEvent(object sender, EventArgs eventArgs)
        {
            TvEngine.Events.TvServerEventArgs args = eventArgs as TvEngine.Events.TvServerEventArgs;

            if (args == null)
            {
                return;
            }

            Log.Debug("TVServerKodi: OnTvServerEvent: " + args.EventType.ToString());

            if (args.EventType == TvEngine.Events.TvServerEventType.ImportEpgPrograms &&
                args.EpgChannel != null &&
                args.EpgChannel.Programs.Count > 0)
            {
                try
                {
                    if (args.channel != null)
                    {
                        Log.Info("TVServerKodi: EPG import for channel: " + args.channel.Name);
                    }

                    TvLibrary.Channels.DVBBaseChannel dvbChannel = args.EpgChannel.Channel as TvLibrary.Channels.DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.TvBusinessLayer layer     = new TvDatabase.TvBusinessLayer();
                        TvDatabase.Channel         mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("TVServerKodi: received {0} programs on {1}", args.EpgChannel.Programs.Count, mpChannel.DisplayName);
                            //foreach (TvLibrary.Epg.EpgProgram p in args.EpgChannel.Programs)
                            //{
                            //  Log.Info("TVServerKodi: program: " + p.StartTime.ToString() + "-" + p.EndTime.ToString());
                            //}
                        }
                    }
                    //ImportEpgPrograms(args.EpgChannel);
                }
                catch (Exception ex)
                {
                    Log.Error("TVServerKodi: ImportEpgPrograms(): {0}", ex.Message);
                }
            }
        }
示例#2
0
        private void ImportEpgPrograms(EpgChannel epgChannel)
        {
            if (!this.IsArgusTVConnectionInitialized)
            {
                InitializeArgusTVConnection(null);
            }
            if (this.IsArgusTVConnectionInitialized)
            {
                TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
                bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value);
                if (epgSyncOn)
                {
                    DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName);

                            bool   epgSyncAutoCreateChannels          = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value);
                            bool   epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value);
                            string epgLanguages = layer.GetSetting("epgLanguages").Value;

                            Channel channel = EnsureChannelForDvbEpg(mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup);
                            if (channel != null)
                            {
                                EnsureGuideChannelForDvbEpg(channel, mpChannel);

                                List <GuideProgram> guidePrograms = new List <GuideProgram>();

                                foreach (EpgProgram epgProgram in epgChannel.Programs)
                                {
                                    string title;
                                    string description;
                                    string genre;
                                    int    starRating;
                                    string classification;
                                    int    parentalRating;
                                    GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre,
                                                              out starRating, out classification, out parentalRating);

                                    if (!String.IsNullOrEmpty(title))
                                    {
                                        GuideProgram guideProgram = new GuideProgram();
                                        guideProgram.GuideChannelId = channel.GuideChannelId.Value;
                                        guideProgram.StartTime      = epgProgram.StartTime;
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StartTimeUtc   = epgProgram.StartTime.ToUniversalTime();
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StopTimeUtc    = epgProgram.EndTime.ToUniversalTime();
                                        guideProgram.Title          = title;
                                        guideProgram.Description    = description;
                                        guideProgram.Category       = genre;
                                        guideProgram.Rating         = classification;
                                        guideProgram.StarRating     = starRating / 7.0;
                                        guidePrograms.Add(guideProgram);
                                    }
                                }

                                _dvbEpgThread.ImportProgramsAsync(guidePrograms);
                            }
                            else
                            {
                                Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel.");
                            }
                        }
                        else
                        {
                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel.");
                        }
                    }
                }
            }
        }
        private void ImportEpgPrograms(EpgChannel epgChannel)
        {
            if (!this.IsArgusTVConnectionInitialized)
            {
                InitializeArgusTVConnection(null);
            }
            if (this.IsArgusTVConnectionInitialized)
            {
                TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
                bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value);
                if (epgSyncOn)
                {
                    DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName);

                            using (CoreServiceAgent coreAgent = new CoreServiceAgent())
                            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                            using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
                            {
                                bool epgSyncAutoCreateChannels = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value);
                                bool epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value);
                                string epgLanguages = layer.GetSetting("epgLanguages").Value;

                                Channel channel = EnsureChannelForDvbEpg(tvSchedulerAgent, mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup);
                                if (channel != null)
                                {
                                    EnsureGuideChannelForDvbEpg(tvSchedulerAgent, tvGuideAgent, channel, mpChannel);

                                    List<GuideProgram> guidePrograms = new List<GuideProgram>();

                                    foreach (EpgProgram epgProgram in epgChannel.Programs)
                                    {
                                        string title;
                                        string description;
                                        string genre;
                                        int starRating;
                                        string classification;
                                        int parentalRating;
                                        GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre,
                                            out starRating, out classification, out parentalRating);

                                        if (!String.IsNullOrEmpty(title))
                                        {
                                            GuideProgram guideProgram = new GuideProgram();
                                            guideProgram.GuideChannelId = channel.GuideChannelId.Value;
                                            guideProgram.StartTime = epgProgram.StartTime;
                                            guideProgram.StopTime = epgProgram.EndTime;
                                            guideProgram.StartTimeUtc = epgProgram.StartTime.ToUniversalTime();
                                            guideProgram.StopTime = epgProgram.EndTime;
                                            guideProgram.StopTimeUtc = epgProgram.EndTime.ToUniversalTime();
                                            guideProgram.Title = title;
                                            guideProgram.Description = description;
                                            guideProgram.Category = genre;
                                            guideProgram.Rating = classification;
                                            guideProgram.StarRating = starRating / 7.0;
                                            guidePrograms.Add(guideProgram);
                                        }
                                    }

                                    _dvbEpgThread.ImportProgramsAsync(guidePrograms);
                                }
                                else
                                {
                                    Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel.");
                                }
                            }
                        }
                        else
                        {
                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel.");
                        }
                    }
                }
            }
        }
示例#4
0
        private void events_OnTvServerEvent(object sender, EventArgs eventArgs)
        {
            TvEngine.Events.TvServerEventArgs args = eventArgs as TvEngine.Events.TvServerEventArgs;

            if (args == null)
              return;

            Log.Debug("TVServerKodi: OnTvServerEvent: " + args.EventType.ToString());

            if (args.EventType == TvEngine.Events.TvServerEventType.ImportEpgPrograms
            && args.EpgChannel != null
            && args.EpgChannel.Programs.Count > 0)
            {
              try
              {
            if (args.channel != null)
              Log.Info("TVServerKodi: EPG import for channel: " + args.channel.Name);

            TvLibrary.Channels.DVBBaseChannel dvbChannel = args.EpgChannel.Channel as TvLibrary.Channels.DVBBaseChannel;
            if (dvbChannel != null)
            {
              TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
              TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
              if (mpChannel != null)
              {
                Log.Debug("TVServerKodi: received {0} programs on {1}", args.EpgChannel.Programs.Count, mpChannel.DisplayName);
                //foreach (TvLibrary.Epg.EpgProgram p in args.EpgChannel.Programs)
                //{
                //  Log.Info("TVServerKodi: program: " + p.StartTime.ToString() + "-" + p.EndTime.ToString());
                //}
              }
            }
            //ImportEpgPrograms(args.EpgChannel);
              }
              catch (Exception ex)
              {
            Log.Error("TVServerKodi: ImportEpgPrograms(): {0}", ex.Message);
              }
            }
        }