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.");
                        }
                    }
                }
            }
        }
Beispiel #2
0
    /// <summary>
    /// checks if a received EPGChannel should be filtered from the resultlist
    /// </summary>
    /// <value></value>
    protected override bool FilterOutEPGChannel(EpgChannel epgChannel)
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      if (layer.GetSetting("generalGrapOnlyForSameTransponder", "no").Value == "yes")
      {
        DVBBaseChannel chan = epgChannel.Channel as DVBBaseChannel;
        Channel dbchannel = layer.GetChannelByTuningDetail(chan.NetworkId, chan.TransportId, chan.ServiceId);
        DVBTChannel dvbtchannel = new DVBTChannel();
        if (dbchannel == null)
        {
          return false;
        }
        foreach (TuningDetail detail in dbchannel.ReferringTuningDetail())
        {
          if (detail.ChannelType == 4)
          {
            dvbtchannel.Frequency = detail.Frequency;
            dvbtchannel.BandWidth = detail.Bandwidth;
          }
        }
        return this.CurrentChannel.IsDifferentTransponder(dvbtchannel);
      }
      else
        return false;

    }
Beispiel #3
0
 /// <summary>
 /// checks if a received EPGChannel should be filtered from the resultlist
 /// </summary>
 /// <value></value>
 protected override bool FilterOutEPGChannel(EpgChannel epgChannel)
 {
   TvBusinessLayer layer = new TvBusinessLayer();
   if (layer.GetSetting("generalGrapOnlyForSameTransponder", "no").Value == "yes")
   {
     DVBBaseChannel chan = epgChannel.Channel as DVBBaseChannel;
     Channel dbchannel = layer.GetChannelByTuningDetail(chan.NetworkId, chan.TransportId, chan.ServiceId);
     DVBSChannel dvbschannel = new DVBSChannel();
     if (dbchannel == null)
     {
       return false;
     }
     foreach (TuningDetail detail in dbchannel.ReferringTuningDetail())
     {
       if (detail.ChannelType == 3)
       {
         dvbschannel.Frequency = detail.Frequency;
         dvbschannel.Polarisation = (Polarisation)detail.Polarisation;
         dvbschannel.ModulationType = (ModulationType)detail.Modulation;
         dvbschannel.SatelliteIndex = detail.SatIndex;
         dvbschannel.InnerFecRate = (BinaryConvolutionCodeRate)detail.InnerFecRate;
         dvbschannel.Pilot = (Pilot)detail.Pilot;
         dvbschannel.Rolloff = (RollOff)detail.RollOff;
         dvbschannel.DisEqc = (DisEqcType)detail.Diseqc;
       }
     }
     return this.CurrentChannel.IsDifferentTransponder(dvbschannel);
   }
   else
     return false;  
 }
 /// <summary>
 /// checks if a received EPGChannel should be filtered from the resultlist
 /// </summary>
 /// <value></value>
 protected virtual bool FilterOutEPGChannel(EpgChannel epgChannel)
 {
   return false;
 }
 /// <summary>
 /// This method will be called by the EPG grabber.
 /// </summary>
 public void OnImportEpgPrograms(EpgChannel epgChannel)
 {
   try
   {
     TvServerEventArgs eventArgs = new TvServerEventArgs(TvServerEventType.ImportEpgPrograms, epgChannel);
     Fire(this, eventArgs);
   }
   catch (Exception ex)
   {
     Log.Write(ex);
     return;
   }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TvServerEventArgs"/> class.
 /// </summary>
 /// <param name="eventType">Type of the event.</param>
 /// <param name="epgChannel">The epg channel</param>
 public TvServerEventArgs(TvServerEventType eventType, EpgChannel epgChannel)
 {
   _eventType = eventType;
   _epgChannel = epgChannel;
 }
 /// <summary>
 /// checks if a received EPGChannel should be filtered from the resultlist
 /// </summary>
 /// <value></value>
 protected override bool FilterOutEPGChannel(EpgChannel epgChannel)
 {
   TvBusinessLayer layer = new TvBusinessLayer();
   if (layer.GetSetting("generalGrapOnlyForSameTransponder", "no").Value == "yes")
   {
     DVBBaseChannel chan = epgChannel.Channel as DVBBaseChannel;
     Channel dbchannel = layer.GetChannelByTuningDetail(chan.NetworkId, chan.TransportId, chan.ServiceId);
     ATSCChannel atscchannel = new ATSCChannel();
     if (dbchannel == null)
     {
       return false;
     }
     foreach (TuningDetail detail in dbchannel.ReferringTuningDetail())
     {
       if (detail.ChannelType == 1)
       {
         atscchannel.MajorChannel = detail.MajorChannel;
         atscchannel.MinorChannel = detail.MinorChannel;
         atscchannel.PhysicalChannel = detail.ChannelNumber;
       }
     }
     return this.CurrentChannel.IsDifferentTransponder(atscchannel);
   }
   else
     return false;
 }