Custom Data Grabber including Sky UK Channel/EPG Grabber (5 Viewers)

DJBlu

Portal Pro
August 14, 2007
1,670
813
Llanelli
Home Country
United Kingdom United Kingdom
@Benoire

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:

Benoire

MP Donator
  • Premium Supporter
  • March 17, 2012
    679
    161
    45
    Auckland
    Home Country
    New Zealand New Zealand
    No, causes the same error to occur... Thanks for trying though, I'm not sure where it is failing. Are you able to debug TVServer plugins in VS as I couldn't get any break points working at all; the plugin just runs normally unless I manually break all progress and step through manually.
     

    DJBlu

    Portal Pro
    August 14, 2007
    1,670
    813
    Llanelli
    Home Country
    United Kingdom United Kingdom
    No, causes the same error to occur... Thanks for trying though, I'm not sure where it is failing. Are you able to debug TVServer plugins in VS as I couldn't get any break points working at all; the plugin just runs normally unless I manually break all progress and step through manually.

    Have you tried deleting your database?

    If there is any errors with the data then it can cause a problem.
     

    Benoire

    MP Donator
  • Premium Supporter
  • March 17, 2012
    679
    161
    45
    Auckland
    Home Country
    New Zealand New Zealand
    Hi

    Could the error be in the update database bit? I've just copied the output window from an updated version of the plugin which doesn't stop on the error but logs it and the plugin has grabbed all the data from the stream...
    output.PNG


    Thoughts?
     

    DJBlu

    Portal Pro
    August 14, 2007
    1,670
    813
    Llanelli
    Home Country
    United Kingdom United Kingdom
    It's hard to say.

    If you remove the try, catch and end try, also comment out the MessageBox in the UpdateAddChannels sub it will debug providing you attach the process to VS. This is there to catch the error. It will debug to the line that is causing the issue.

    Once I know this then I can help out.
     

    richardc1983

    Portal Pro
    October 10, 2012
    251
    24
    Leeds
    Home Country
    United Kingdom United Kingdom
    Hey all having some issues...

    I'm in the uk West Yorkshire region. Did a rescan recently and even though use sky numbering & sky region is ticked and region is set correctly it is still adding all the other BBC and itv regions so this creates duplicate channels and some of them showing as channel 1000. Before the re scan it would automatically delete these and not use them or place them in the epg guide. Now I'm having to manually go in and do it. It's a pain when I click on a programme and view upcoming episodes and it shows that programme on ever single region repeat an all.

    Any idea what's gone wrong? I've tried rescanning which then shuffled the regions round and set the wrong one then rescanned again and it just put it back to how it is now.

    Only error I've noticed when I grab data is it shows "error decoding summary - index was outside the bounds of the array" not sure if seen that before.

    Thanks
     

    Benoire

    MP Donator
  • Premium Supporter
  • March 17, 2012
    679
    161
    45
    Auckland
    Home Country
    New Zealand New Zealand
    The error is what normally causes the abnormal grab in my experience, I get it sometimes and when I do it doesn't add all the EPG data or other stuff. I can only assume that it is because the header containing the data is slightly different (I.e. the part of the header that deals with the sky event is longer than expected.

    Not much you can do about it at the moment I think until we can get the code back to the same level that DJBlu posted here (i.e. 1.4.0.6 for UK).[DOUBLEPOST=1399486934][/DOUBLEPOST]
    Is this working for Sky Germany? Does it use DVB EPG?
    The modification uses custom plugins which are setup to deal with the various Sky systems. For the UK, NZ and Italy it will scan for OpenTV data and decode that to give you LCNs, channel names, events and series link ( aswell as auto add/remove etc.)

    You could try the mods and use the Sky UK plugin? You'll need to know the frequency, symbol rate, Transport ID and Service ID of the transponder that transmits the OpenTV data and then change the default settings on the UK one to see if it works.
     
    Last edited:

    Stéphane Lenclud

    Retired Team Member
  • Premium Supporter
  • April 29, 2013
    2,576
    1,294
    Home Country
    Germany Germany
    So basically it does all what your sky receiver does, right? Sounds too good to be true. How comes nobody from the German community has ever tried that stuff? Why is it not part of the main distribution? I'm already on 1.7.1 and too busy right now to try it out but I'll certainly give a try at some point.
     

    Benoire

    MP Donator
  • Premium Supporter
  • March 17, 2012
    679
    161
    45
    Auckland
    Home Country
    New Zealand New Zealand
    Pretty much yes. It will add/delete, group, sort by channel number, record by series link, even do regionalised channel work (i.e. if you have four identical channel but each channel has say a news show that is tailored to that region, you can select that region and you'll get all the right channels. This does require the region information to be present in the plugin code, which is why you see individual country plugins as they're all slightly different).

    Its unfortunately not part of the main distribution because the community hasn't presented a good enough case to the Devs, that TVE3 is in code freeze now, and unfortunately the process can be quite IOPS intensive. I believe something similar will come for TVE3.5 in time but until then this code is our best friend :)

    Unless someone merges the code with 1.7.1 before me, I will attempt to do so in a few weeks, I'm currently rebuilding the plugin code to the latest UK set so that we all have a common base to start from for changes as unfortunately DJBlu had a HDD failure which lost the source code he created. Once done AND working correctly (i'm using a combination of decompiled dll and a very old source) it will be posted here and then people will be free to add features or make it work in other countries.
     

    Users who are viewing this thread

    Top Bottom