- Thread starter
- #2,831
@Benoire
Try this, replace the AddRemoveChannels sub with the following
Try this, replace the AddRemoveChannels sub with the following
Code:
Public Sub UpdateAddChannels()
Try
Dim DiseqC As Integer = Settings.DiseqC
Dim UseSkyNumbers As Boolean = Settings.UseSkyNumbers
Dim SwitchingFrequency As Integer = Settings.SwitchingFrequency
Dim UseSkyRegions As Boolean = Settings.UseSkyRegions
Dim UseSkyCategories As Boolean = Settings.UseSkyCategories
Dim ChannelsAdded As Integer = 0
Dim UseModNotSetSD As Boolean = Settings.UseNotSetModSD
Dim UseModNotSetHD As Boolean = Settings.UseNotSetModHD
Dim IgnoreScrambled As Boolean = Settings.IgnoreScrambled
Dim NID As Integer = Settings.NID
Dim channel As New DVBSChannel
Dim currentDetail As TuningDetail
If (Not OnMessageEvent Is Nothing) Then
RaiseEvent OnMessage("", False)
End If
For Each pair As KeyValuePair(Of Integer, Sky_Channel) In Channels
'//Dim detail As TuningDetail - Needs rest of Sky filtering work.
ChannelsAdded += 1
RaiseEvent OnMessage("(" & ChannelsAdded & "/" & Channels.Count & ") Channels sorted", True)
Dim ChannelId As Integer = pair.Key
Dim ScannedChannel As Sky_Channel = pair.Value
If ChannelId < 1 Then Continue For
If ScannedChannel.NID = 0 Or ScannedChannel.TID = 0 Or ScannedChannel.SID = 0 Then
Continue For
End If
Dim SDT As SDTInfo = GetChannelbySID(ScannedChannel.NID & "-" & ScannedChannel.TID & "-" & ScannedChannel.SID)
If SDT Is Nothing Then
Continue For
End If
If SDT Is Nothing Then
Continue For
End If
If IgnoreScrambled And SDT.isFTA Then
Continue For
End If
Dim checker As Channel = _layer.GetChannelbyExternalID(ScannedChannel.NID & ":" & ScannedChannel.ChannelID.ToString)
currentDetail = Nothing
If Not checker Is Nothing Then
Dim Channels As List(Of TuningDetail) = checker.ReferringTuningDetail
If Channels Is Not Nothing Then
For Each Chann As TuningDetail In Channels
If Chann.ChannelType = 3 And Chann.NetworkId = 169 Then
currentDetail = Chann
Exit For
End If
Next
End If
End If
'Add New Channel
If currentDetail Is Nothing Then
GoTo AddNewChannel
End If
AddNewChannel:
If Not NITInfo.ContainsKey(ScannedChannel.TID) Then
'no nit info
RaiseEvent OnMessage("No NIT found for : " & ScannedChannel.SID, False)
RaiseEvent OnMessage("", False)
Continue For
End If
''//this stuff appears missing:
Dim channelNumber As Integer = 10000
Dim VisibleInGuide As Boolean = True
If (UseSkyNumbers And (ScannedChannel.LCNCount > 0)) Then
If ScannedChannel.ContainsLCN(Me.BouquetIDtoUse, Me.RegionIDtoUse) Then
channelNumber = ScannedChannel.GetLCN(Me.BouquetIDtoUse, Me.RegionIDtoUse).SkyNum
If ScannedChannel.ContainsLCN(Me.BouquetIDtoUse, 255) Then
channelNumber = ScannedChannel.GetLCN(Me.BouquetIDtoUse, 255).SkyNum
End If
End If
If (channelNumber = 10000) Then
VisibleInGuide = False
End If
End If
Dim DBChannel As Channel = _layer.AddNewChannel(SDT.ChannelName, channelNumber)
Dim NIT As NITSatDescriptor = NITInfo(ScannedChannel.TID)
DVBSChannel.BandType = 0
DVBSChannel.DisEqc = DirectCast(DiseqC, DisEqcType)
DVBSChannel.FreeToAir = True
DVBSChannel.Frequency = NIT.Frequency
DVBSChannel.SymbolRate = NIT.Symbolrate
DVBSChannel.InnerFecRate = DirectCast(NIT.FECInner, DirectShowLib.BDA.BinaryConvolutionCodeRate)
DVBSChannel.IsRadio = SDT.isRadio
DVBSChannel.IsTv = SDT.isTV
DVBSChannel.FreeToAir = Not SDT.isFTA
DBChannel.ChannelNumber = channelNumber
DBChannel.SortOrder = channelNumber
DBChannel.VisibleInGuide = VisibleInGuide
If (NIT.isS2 And UseModNotSetHD) Or (NIT.isS2 = False And UseModNotSetSD) Then
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotSet
Else
Select Case NIT.Modulation
Case 1
If NIT.isS2 Then
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNbcQpsk
Else
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModQpsk
End If
Case 2
If NIT.isS2 Then
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNbc8Psk
Else
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotDefined
End If
Case Else
DVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotDefined
End Select
End If
DVBSChannel.Name = SDT.ChannelName
DVBSChannel.NetworkId = ScannedChannel.NID
DVBSChannel.Pilot = -1
DVBSChannel.Rolloff = -1
If NIT.isS2 = 1 Then
DVBSChannel.Rolloff = CType(NIT.RollOff, DirectShowLib.BDA.RollOff)
End If
DVBSChannel.PmtPid = 0
DVBSChannel.Polarisation = CType(NIT.Polarisation, DirectShowLib.BDA.Polarisation)
DVBSChannel.Provider = SDT.Provider
DVBSChannel.ServiceId = ScannedChannel.SID
DVBSChannel.TransportId = ScannedChannel.TID
DVBSChannel.SwitchingFrequency = SwitchingFrequency ' Option for user to enter
DBChannel.IsRadio = SDT.isRadio
DBChannel.IsTv = SDT.isTV
DBChannel.ExternalId = ScannedChannel.NID & ":" & ScannedChannel.ChannelID.ToString
DBChannel.Persist()
MapChannelToCards(DBChannel)
AddChannelToGroups(DBChannel, SDT, DVBSChannel, UseSkyCategories)
_layer.AddTuningDetails(DBChannel, DVBSChannel)
DBChannel = currentDetail.ReferencedChannel()
If DBChannel.ExternalId <> ScannedChannel.NID & ":" & ChannelId.ToString Then
'Problem with TVServer so need to add new channel.
GoTo AddNewChannel
End If
Dim checkDVBSChannel As DVBSChannel = _layer.GetTuningChannel(currentDetail)
If checkDVBSChannel Is Nothing Then
Continue For
End If
If DBChannel Is Nothing Then
Continue For
End If
Dim Checksdt As SDTInfo
If SDTInfo.ContainsKey(ScannedChannel.NID & "-" & ScannedChannel.TID & "-" & ScannedChannel.SID) Then
Dim haschanged As Boolean = False
Dim deleteepg As Boolean = False
Checksdt = SDTInfo(ScannedChannel.NID & "-" & ScannedChannel.TID & "-" & ScannedChannel.SID)
If DBChannel.DisplayName <> Checksdt.ChannelName Or currentDetail.Name <> Checksdt.ChannelName Then
RaiseEvent OnMessage("Channel " & DBChannel.DisplayName & " name changed to " & Checksdt.ChannelName, False)
DBChannel.DisplayName = Checksdt.ChannelName
checkDVBSChannel.Name = Checksdt.ChannelName
'Check Channel hasn't become a real channel from a test channel
If ScannedChannel.LCNCount > 0 And DBChannel.VisibleInGuide = False Then
DBChannel.VisibleInGuide = True
RaiseEvent OnMessage("Channel " & DBChannel.DisplayName & " is now part of the EPG making visible " & Checksdt.ChannelName & ".", False)
End If
haschanged = True
End If
If checkDVBSChannel.Provider <> Checksdt.Provider Then
RaiseEvent OnMessage("Channel " & DBChannel.DisplayName & " Provider name changed to " & Checksdt.Provider & ".", False)
RaiseEvent OnMessage("", False)
checkDVBSChannel.Provider = Checksdt.Provider
haschanged = True
End If
If currentDetail.TransportId <> ScannedChannel.TID Then
'Moved transponder
RaiseEvent OnMessage("Channel : " & DBChannel.DisplayName & " tuning details changed.", False)
RaiseEvent OnMessage("", False)
If NITInfo.ContainsKey(ScannedChannel.TID) Then
NIT = NITInfo(ScannedChannel.TID)
Else
Continue For
End If
checkDVBSChannel.BandType = 0
checkDVBSChannel.Frequency = NIT.Frequency
checkDVBSChannel.SymbolRate = NIT.Symbolrate
checkDVBSChannel.InnerFecRate = CType(NIT.FECInner, DirectShowLib.BDA.BinaryConvolutionCodeRate)
If (NIT.isS2 And UseModNotSetHD) Or (NIT.isS2 = False And UseModNotSetSD) Then
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotSet
Else
Select Case NIT.Modulation
Case 1
If NIT.isS2 Then
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNbcQpsk
Else
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModQpsk
End If
Case 2
If NIT.isS2 Then
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNbc8Psk
Else
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotDefined
End If
Case Else
checkDVBSChannel.ModulationType = DirectShowLib.BDA.ModulationType.ModNotDefined
End Select
End If
checkDVBSChannel.Pilot = -1
checkDVBSChannel.Rolloff = -1
If NIT.isS2 = 1 Then
checkDVBSChannel.Rolloff = CType(NIT.RollOff, DirectShowLib.BDA.RollOff)
End If
checkDVBSChannel.PmtPid = 0
checkDVBSChannel.Polarisation = CType(NIT.Polarisation, DirectShowLib.BDA.Polarisation)
checkDVBSChannel.TransportId = ScannedChannel.TID
checkDVBSChannel.SwitchingFrequency = SwitchingFrequency ' Option for user to enter
haschanged = True
deleteepg = True
RaiseEvent OnMessage("Channel : " & DBChannel.DisplayName & " tuning details changed.", False)
RaiseEvent OnMessage("", False)
End If
If currentDetail.ServiceId <> ScannedChannel.SID Then
checkDVBSChannel.ServiceId = ScannedChannel.SID
checkDVBSChannel.PmtPid = 0
RaiseEvent OnMessage("Channel : " & DBChannel.DisplayName & " serviceID changed.", False)
RaiseEvent OnMessage("", False)
haschanged = True
deleteepg = True
End If
If UseSkyRegions = True Then
Dim checkLCN As Integer = 10000
If UseSkyNumbers Then
If ScannedChannel.LCNCount > 0 Then
If ScannedChannel.ContainsLCN(BouquetIDtoUse, RegionIDtoUse) Then
Dim LCN As LCNHolder = ScannedChannel.GetLCN(BouquetIDtoUse, RegionIDtoUse)
checkLCN = LCN.SkyNum
Else
If ScannedChannel.ContainsLCN(BouquetIDtoUse, 255) Then
Dim LCN As LCNHolder = ScannedChannel.GetLCN(BouquetIDtoUse, 255)
checkLCN = LCN.SkyNum
End If
End If
If (currentDetail.ChannelNumber <> checkLCN And checkLCN < 1000) Or (checkLCN = 10000 And DBChannel.SortOrder <> 10000) Then
RaiseEvent OnMessage("Channel : " & DBChannel.DisplayName & " number has changed from : " & checkDVBSChannel.LogicalChannelNumber & " to : " & checkLCN & ".", False)
RaiseEvent OnMessage("", False)
DBChannel.RemoveFromAllGroups()
currentDetail.ChannelNumber = checkLCN
checkDVBSChannel.LogicalChannelNumber = checkLCN
DBChannel.SortOrder = checkLCN
DBChannel.VisibleInGuide = True
haschanged = True
AddChannelToGroups(DBChannel, Checksdt, checkDVBSChannel, UseSkyCategories)
End If
End If
End If
End If
If haschanged Then
DBChannel.Persist()
Dim tuning As TuningDetail = _layer.UpdateTuningDetails(DBChannel, checkDVBSChannel, currentDetail)
If tuning Is Not Nothing Then
tuning.Persist()
MapChannelToCards(DBChannel)
If deleteepg Then
_layer.RemoveAllPrograms(DBChannel.IdChannel)
End If
End If
End If
End If
Next
Catch err As Exception
MsgBox(err.Message)
End Try
End Sub
Last edited: