Example #1
0
        /// <summary>
        /// Add a time offset entry to the collection.
        /// </summary>
        /// <param name="newEntry">The entry to be added.</param>
        public static void AddEntry(TimeOffsetEntry newEntry)
        {
            foreach (TimeOffsetEntry oldEntry in TimeOffsets)
            {
                if (oldEntry.CountryCode == newEntry.CountryCode && oldEntry.Region == newEntry.Region)
                {
                    return;
                }

                if (oldEntry.CountryCode == newEntry.CountryCode)
                {
                    if (oldEntry.Region > newEntry.Region)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
                else
                {
                    if (oldEntry.CountryCode.CompareTo(newEntry.CountryCode) > 0)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
            }

            TimeOffsets.Add(newEntry);
        }
Example #2
0
        private void setTimeOffset()
        {
            if (TimeOffsetEntry.TimeOffsets.Count == 0)
            {
                TimeOffsetEntry.CurrentTimeOffset      = new TimeSpan();
                TimeOffsetEntry.FutureTimeOffset       = new TimeSpan();
                TimeOffsetEntry.TimeOfFutureTimeOffset = new DateTime();
                Logger.Instance.Write("No local time offset in effect");
                return;
            }

            if (TimeOffsetEntry.TimeOffsets.Count == 1)
            {
                TimeOffsetEntry.CurrentTimeOffset      = TimeOffsetEntry.TimeOffsets[0].TimeOffset;
                TimeOffsetEntry.FutureTimeOffset       = TimeOffsetEntry.TimeOffsets[0].NextTimeOffset;
                TimeOffsetEntry.TimeOfFutureTimeOffset = TimeOffsetEntry.TimeOffsets[0].ChangeTime;
                Logger.Instance.Write("Local time offset set to " + TimeOffsetEntry.TimeOffsets[0].TimeOffset +
                                      " for country " + TimeOffsetEntry.TimeOffsets[0].CountryCode +
                                      " region " + TimeOffsetEntry.TimeOffsets[0].Region);
                Logger.Instance.Write("Time offset will change to " + TimeOffsetEntry.TimeOffsets[0].NextTimeOffset +
                                      " at " + TimeOffsetEntry.TimeOffsets[0].ChangeTime);
                return;
            }

            if (RunParameters.Instance.CountryCode != null)
            {
                TimeOffsetEntry offsetEntry = TimeOffsetEntry.FindEntry(RunParameters.Instance.CountryCode, RunParameters.Instance.Region);
                if (offsetEntry != null)
                {
                    TimeOffsetEntry.CurrentTimeOffset      = offsetEntry.TimeOffset;
                    TimeOffsetEntry.FutureTimeOffset       = offsetEntry.NextTimeOffset;
                    TimeOffsetEntry.TimeOfFutureTimeOffset = offsetEntry.ChangeTime;
                    Logger.Instance.Write("Local time offset set to " + offsetEntry.TimeOffset +
                                          " for country " + offsetEntry.CountryCode +
                                          " region " + offsetEntry.Region);
                    Logger.Instance.Write("Time offset will change to " + offsetEntry.NextTimeOffset +
                                          " at " + offsetEntry.ChangeTime);
                }
                else
                {
                    TimeOffsetEntry.CurrentTimeOffset      = new TimeSpan();
                    TimeOffsetEntry.FutureTimeOffset       = new TimeSpan();
                    TimeOffsetEntry.TimeOfFutureTimeOffset = new DateTime();
                    Logger.Instance.Write("No local time offset in effect");
                }
            }
            else
            {
                TimeOffsetEntry.CurrentTimeOffset      = new TimeSpan();
                TimeOffsetEntry.FutureTimeOffset       = new TimeSpan();
                TimeOffsetEntry.TimeOfFutureTimeOffset = new DateTime();
                Logger.Instance.Write("No local time offset in effect");
            }
        }
        private void processEvent(int frequency, int sourceID, EventInformationTableEntry eventEntry)
        {
            VirtualChannel channel = VirtualChannelTable.FindChannel(frequency, sourceID);

            if (channel == null)
            {
                return;
            }

            EPGEntry epgEntry = new EPGEntry();

            epgEntry.EventID = eventEntry.EventID;

            if (eventEntry.EventName != null)
            {
                epgEntry.EventName = eventEntry.EventName.ToString().Replace("\0", "");
            }
            else
            {
                epgEntry.EventName = "No Event Name";
            }

            if (eventEntry.ETMLocation == 1 || eventEntry.ETMLocation == 2)
            {
                ExtendedTextTableEntry textEntry = ExtendedTextTable.FindEntry(sourceID, eventEntry.EventID);
                if (textEntry != null)
                {
                    epgEntry.ShortDescription = textEntry.Text.ToString().Replace("\0", "");
                }
            }

            epgEntry.StartTime            = Utils.RoundTime(TimeOffsetEntry.GetAdjustedTime(eventEntry.StartTime));
            epgEntry.Duration             = Utils.RoundTime(eventEntry.Duration);
            epgEntry.EventCategory        = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, eventEntry);
            epgEntry.ParentalRating       = eventEntry.ParentalRating;
            epgEntry.ParentalRatingSystem = "VCHIP";
            epgEntry.AudioQuality         = eventEntry.AudioQuality;
            epgEntry.EPGSource            = EPGSource.PSIP;

            channel.AddEPGEntry(epgEntry);
        }
Example #4
0
        private void processTimeOffsetSections(Collection <Mpeg2Section> sections)
        {
            foreach (Mpeg2Section section in sections)
            {
                TimeOffsetSection timeOffsetSection = TimeOffsetSection.ProcessTimeOffsetTable(section.Data);
                if (timeOffsetSection != null)
                {
                    if (timeOffsetSection.Descriptors != null)
                    {
                        foreach (DescriptorBase descriptor in timeOffsetSection.Descriptors)
                        {
                            DVBLocalTimeOffsetDescriptor timeOffsetDescriptor = descriptor as DVBLocalTimeOffsetDescriptor;
                            if (timeOffsetDescriptor != null)
                            {
                                foreach (DVBLocalTimeOffsetEntry entry in timeOffsetDescriptor.TimeOffsetEntries)
                                {
                                    TimeOffsetEntry offsetEntry = new TimeOffsetEntry();
                                    offsetEntry.CountryCode = entry.CountryCode;
                                    offsetEntry.Region      = entry.Region;

                                    if (entry.OffsetPositive)
                                    {
                                        offsetEntry.TimeOffset     = entry.TimeOffset;
                                        offsetEntry.NextTimeOffset = entry.NextTimeOffset;
                                    }
                                    else
                                    {
                                        offsetEntry.TimeOffset     = new TimeSpan() - entry.TimeOffset;
                                        offsetEntry.NextTimeOffset = new TimeSpan() - entry.NextTimeOffset;
                                    }

                                    offsetEntry.ChangeTime = entry.ChangeTime;

                                    TimeOffsetEntry.AddEntry(offsetEntry);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        private void processTimeOffsetSections(Collection<Mpeg2Section> sections)
        {
            foreach (Mpeg2Section section in sections)
            {
                TimeOffsetSection timeOffsetSection = TimeOffsetSection.ProcessTimeOffsetTable(section.Data);
                if (timeOffsetSection != null)
                {
                    if (timeOffsetSection.Descriptors != null)
                    {
                        foreach (DescriptorBase descriptor in timeOffsetSection.Descriptors)
                        {
                            DVBLocalTimeOffsetDescriptor timeOffsetDescriptor = descriptor as DVBLocalTimeOffsetDescriptor;
                            if (timeOffsetDescriptor != null)
                            {
                                foreach (DVBLocalTimeOffsetEntry entry in timeOffsetDescriptor.TimeOffsetEntries)
                                {
                                    TimeOffsetEntry offsetEntry = new TimeOffsetEntry();
                                    offsetEntry.CountryCode = entry.CountryCode;
                                    offsetEntry.Region = entry.Region;

                                    if (entry.OffsetPositive)
                                    {
                                        offsetEntry.TimeOffset = entry.TimeOffset;
                                        offsetEntry.NextTimeOffset = entry.NextTimeOffset;
                                    }
                                    else
                                    {
                                        offsetEntry.TimeOffset = new TimeSpan() - entry.TimeOffset;
                                        offsetEntry.NextTimeOffset = new TimeSpan() - entry.NextTimeOffset;
                                    }

                                    offsetEntry.ChangeTime = entry.ChangeTime;

                                    TimeOffsetEntry.AddEntry(offsetEntry);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Add a time offset entry to the collection.
        /// </summary>
        /// <param name="newEntry">The entry to be added.</param>
        public static void AddEntry(TimeOffsetEntry newEntry)
        {
            foreach (TimeOffsetEntry oldEntry in TimeOffsets)
            {
                if (oldEntry.CountryCode == newEntry.CountryCode && oldEntry.Region == newEntry.Region)
                    return;

                if (oldEntry.CountryCode == newEntry.CountryCode)
                {
                    if (oldEntry.Region > newEntry.Region)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
                else
                {
                    if (oldEntry.CountryCode.CompareTo(newEntry.CountryCode) > 0)
                    {
                        TimeOffsets.Insert(TimeOffsets.IndexOf(oldEntry), newEntry);
                        return;
                    }
                }
            }

            TimeOffsets.Add(newEntry);
        }
Example #7
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            try
            {
                transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                segmentLastSectionNumber = (int)byteData[lastIndex];
                lastIndex++;

                lastTableID = (int)byteData[lastIndex];
                lastIndex++;
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The Bell TV section is short"));
            }

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS"))
                {
                    return;
                }
                else
                {
                    tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID);
                    tvStation.OriginalNetworkID = originalNetworkID;
                    tvStation.TransportStreamID = transportStreamID;
                    tvStation.ServiceID         = serviceID;

                    TVStation.StationCollection.Add(tvStation);
                }
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                BellTVEntry bellTVEntry = new BellTVEntry();
                bellTVEntry.Process(byteData, lastIndex, mpeg2Header.TableID);

                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                epgEntry.TransportStreamID = tvStation.TransportStreamID;
                epgEntry.ServiceID         = tvStation.ServiceID;
                epgEntry.EPGSource         = EPGSource.BellTV;

                if (bellTVEntry.HighDefinition)
                {
                    epgEntry.VideoQuality = "HDTV";
                }
                if (bellTVEntry.ClosedCaptions)
                {
                    epgEntry.SubTitles = "teletext";
                }
                if (bellTVEntry.Stereo)
                {
                    epgEntry.AudioQuality = "stereo";
                }

                epgEntry.Duration  = Utils.RoundTime(bellTVEntry.Duration);
                epgEntry.EventID   = bellTVEntry.EventID;
                epgEntry.EventName = bellTVEntry.EventName;

                getParentalRating(epgEntry, bellTVEntry);

                epgEntry.RunningStatus    = bellTVEntry.RunningStatus;
                epgEntry.Scrambled        = bellTVEntry.Scrambled;
                epgEntry.ShortDescription = bellTVEntry.ShortDescription;
                if (bellTVEntry.SubTitle != bellTVEntry.EventName)
                {
                    epgEntry.EventSubTitle = bellTVEntry.SubTitle;
                }
                epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(bellTVEntry.StartTime));

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, bellTVEntry.ContentType, bellTVEntry.ContentSubType);

                epgEntry.StarRating = getStarRating(bellTVEntry);
                epgEntry.Date       = bellTVEntry.Date;
                epgEntry.Cast       = bellTVEntry.Cast;

                getSeriesEpisode(epgEntry, bellTVEntry.Series, bellTVEntry.Episode);

                epgEntry.HasGraphicLanguage     = bellTVEntry.HasStrongLanguage;
                epgEntry.HasStrongSexualContent = bellTVEntry.HasSexualContent;
                epgEntry.HasGraphicViolence     = bellTVEntry.HasViolence;
                epgEntry.HasNudity = bellTVEntry.HasNudity;

                epgEntry.PreviousPlayDate = bellTVEntry.OriginalAirDate;

                tvStation.AddEPGEntry(epgEntry);

                if (titleLogger != null)
                {
                    logTitle(bellTVEntry.EventName, epgEntry, titleLogger);
                }
                if (descriptionLogger != null)
                {
                    if (!RunParameters.Instance.DebugIDs.Contains("LOGORIGINAL"))
                    {
                        logDescription(bellTVEntry.ShortDescription, epgEntry, descriptionLogger);
                    }
                    else
                    {
                        logDescription(bellTVEntry.OriginalDescription, epgEntry, descriptionLogger);
                    }
                }

                lastIndex = bellTVEntry.Index;
            }
        }
        /// <summary>
        /// Create the EPG entries from the stored title and summary data.
        /// </summary>
        /// <param name="station">The station that the EPG records are for.</param>
        /// <param name="titleLogger">A Logger instance for the program titles.</param>
        /// <param name="descriptionLogger">A Logger instance for the program descriptions.</param>
        /// <param name="collectionType">The type of collection, MHW1 or MHW2.</param>
        public void ProcessChannelForEPG(TVStation station, Logger titleLogger, Logger descriptionLogger, CollectionType collectionType)
        {
            bool     first             = true;
            DateTime expectedStartTime = new DateTime();

            foreach (MediaHighwayTitle title in Titles)
            {
                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = OriginalNetworkID;
                epgEntry.TransportStreamID = TransportStreamID;
                epgEntry.ServiceID         = ServiceID;
                epgEntry.EventID           = title.EventID;

                processEventName(epgEntry, title.EventName);

                MediaHighwaySummary summary = null;

                if (title.SummaryAvailable)
                {
                    summary = findSummary(title.EventID);
                    if (summary != null)
                    {
                        processShortDescription(epgEntry, summary.ShortDescription);
                    }
                    else
                    {
                        if (RunParameters.Instance.DebugIDs.Contains("MHW2SUMMARYMISSING"))
                        {
                            Logger.Instance.Write("Summary missing for event ID " + title.EventID);
                        }
                    }
                }
                if (summary == null)
                {
                    epgEntry.ShortDescription = "No Synopsis Available";
                }

                if (collectionType == CollectionType.MediaHighway1)
                {
                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(title.StartTime));
                }
                else
                {
                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetAdjustedTime(title.StartTime));
                }
                epgEntry.Duration = Utils.RoundTime(title.Duration);

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, title.CategoryID);

                if (collectionType == CollectionType.MediaHighway1)
                {
                    epgEntry.EPGSource = EPGSource.MediaHighway1;
                }
                else
                {
                    epgEntry.EPGSource = EPGSource.MediaHighway2;
                }

                epgEntry.VideoQuality = getVideoQuality(epgEntry.EventName);

                epgEntry.PreviousPlayDate = title.PreviousPlayDate;

                station.AddEPGEntry(epgEntry);

                if (first)
                {
                    expectedStartTime = new DateTime();
                    first             = false;
                }
                else
                {
                    if (epgEntry.StartTime < expectedStartTime)
                    {
                        if (titleLogger != null)
                        {
                            titleLogger.Write(" ** Overlap In Schedule **");
                        }
                    }
                    else
                    {
                        if (RunParameters.Instance.Options.Contains("ACCEPTBREAKS"))
                        {
                            if (epgEntry.StartTime > expectedStartTime + new TimeSpan(0, 5, 0))
                            {
                                if (titleLogger != null)
                                {
                                    titleLogger.Write(" ** Gap In Schedule **");
                                }
                            }
                        }
                        else
                        {
                            if (epgEntry.StartTime > expectedStartTime)
                            {
                                if (titleLogger != null)
                                {
                                    titleLogger.Write(" ** Gap In Schedule **");
                                }
                            }
                        }
                    }
                }

                expectedStartTime = epgEntry.StartTime + epgEntry.Duration;

                if (titleLogger != null)
                {
                    if (collectionType == CollectionType.MediaHighway1)
                    {
                        titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                          " Evt ID " + title.EventID +
                                          " Cat ID " + title.CategoryID.ToString("00") +
                                          " Summary " + title.SummaryAvailable + ":" + (summary != null) + " " +
                                          " Orig Day " + title.LogDay +
                                          " Orig Hours " + title.LogHours +
                                          " YDay " + title.LogYesterday +
                                          " Day " + title.Day +
                                          " Hours " + title.Hours +
                                          " Mins " + title.Minutes + " " +
                                          epgEntry.StartTime.ToShortDateString() + " " +
                                          epgEntry.StartTime.ToString("HH:mm") + " - " +
                                          epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                          title.EventName);
                    }
                    else
                    {
                        titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                          " Evt ID " + title.EventID +
                                          " Cat ID " + title.CategoryID.ToString("000") +
                                          " Main cat " + title.MainCategory +
                                          " Sub cat " + title.SubCategory +
                                          " Summary " + title.SummaryAvailable + ":" + (summary != null) +
                                          " Unknown " + Utils.ConvertToHex(title.Unknown) + " " +
                                          epgEntry.StartTime.ToShortDateString() + " " +
                                          epgEntry.StartTime.ToString("HH:mm") + " - " +
                                          epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                          title.EventName);
                    }
                }

                if (descriptionLogger != null && summary != null)
                {
                    if (collectionType == CollectionType.MediaHighway1)
                    {
                        descriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                                " Evt ID " + title.EventID +
                                                " Rpts: " + summary.ReplayCount + " " +
                                                epgEntry.StartTime.ToShortDateString() + " " +
                                                epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                summary.ShortDescription);
                    }
                    else
                    {
                        descriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                                " Evt ID " + title.EventID + " " +
                                                " Unknown " + Utils.ConvertToHex(summary.Unknown) + " " +
                                                epgEntry.StartTime.ToShortDateString() + " " +
                                                epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                summary.ShortDescription);
                    }
                }

                if (!RunParameters.Instance.Options.Contains("ACCEPTBREAKS"))
                {
                    if (epgEntry.StartTime.Second != 0)
                    {
                        if (titleLogger != null)
                        {
                            titleLogger.Write("** Suspect Start Time **");
                        }
                    }
                }
            }
        }
Example #9
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
            lastIndex        += 2;

            originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
            lastIndex        += 2;

            segmentLastSectionNumber = (int)byteData[lastIndex];
            lastIndex++;

            lastTableID = (int)byteData[lastIndex];
            lastIndex++;

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS"))
                {
                    return;
                }
                else
                {
                    tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID);
                    tvStation.OriginalNetworkID = originalNetworkID;
                    tvStation.TransportStreamID = transportStreamID;
                    tvStation.ServiceID         = serviceID;

                    TVStation.StationCollection.Add(tvStation);
                }
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                EITEntry eitEntry = new EITEntry();
                eitEntry.Process(byteData, lastIndex);

                if (eitEntry.StartTime != DateTime.MinValue)
                {
                    EPGEntry epgEntry = new EPGEntry();
                    epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                    epgEntry.TransportStreamID = tvStation.TransportStreamID;
                    epgEntry.ServiceID         = tvStation.ServiceID;
                    epgEntry.EPGSource         = EPGSource.EIT;

                    switch (eitEntry.ComponentTypeAudio)
                    {
                    case 3:
                        epgEntry.AudioQuality = "stereo";
                        break;

                    case 5:
                        epgEntry.AudioQuality = "dolby digital";
                        break;

                    default:
                        break;
                    }

                    if (eitEntry.ComponentTypeVideo > 9)
                    {
                        epgEntry.VideoQuality = "HDTV";
                    }

                    if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY"))
                    {
                        epgEntry.EventCategory = getEventCategory(eitEntry.EventName, eitEntry.Description, eitEntry.ContentType, eitEntry.ContentSubType);
                    }
                    else
                    {
                        epgEntry.EventCategory = eitEntry.ShortDescription;
                    }

                    epgEntry.Duration  = Utils.RoundTime(eitEntry.Duration);
                    epgEntry.EventID   = eitEntry.EventID;
                    epgEntry.EventName = eitEntry.EventName;

                    if (RunParameters.Instance.CountryCode != null)
                    {
                        epgEntry.ParentalRating     = ParentalRating.FindRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString());
                        epgEntry.MpaaParentalRating = ParentalRating.FindMpaaRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString());
                    }
                    else
                    {
                        if (eitEntry.ParentalRating > 11)
                        {
                            epgEntry.ParentalRating     = "AO";
                            epgEntry.MpaaParentalRating = "AO";
                        }
                        else
                        {
                            if (eitEntry.ParentalRating > 8)
                            {
                                epgEntry.ParentalRating     = "PGR";
                                epgEntry.MpaaParentalRating = "PG";
                            }
                            else
                            {
                                epgEntry.ParentalRating     = "G";
                                epgEntry.MpaaParentalRating = "G";
                            }
                        }
                    }

                    epgEntry.RunningStatus = eitEntry.RunningStatus;
                    epgEntry.Scrambled     = eitEntry.Scrambled;

                    if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY"))
                    {
                        epgEntry.ShortDescription = eitEntry.Description;
                    }
                    else
                    {
                        epgEntry.ShortDescription = eitEntry.ExtendedDescription;
                    }

                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(eitEntry.StartTime));

                    epgEntry.Cast      = eitEntry.Cast;
                    epgEntry.Directors = eitEntry.Directors;
                    epgEntry.Date      = eitEntry.Year;
                    if (eitEntry.TVRating != null)
                    {
                        epgEntry.ParentalRating = eitEntry.TVRating;
                    }
                    epgEntry.StarRating = eitEntry.StarRating;

                    if (eitEntry.TVRating != null)
                    {
                        epgEntry.ParentalRating = eitEntry.TVRating;
                    }

                    setSeriesEpisode(epgEntry, eitEntry);

                    /*if (eitEntry.PreviousPlayDate != null)
                     * {
                     *  try
                     *  {
                     *      TimeSpan offset = new TimeSpan(Int32.Parse(eitEntry.PreviousPlayDate) * TimeSpan.TicksPerSecond);
                     *      epgEntry.PreviousPlayDate = epgEntry.StartTime - offset;
                     *  }
                     *  catch (FormatException) { }
                     * }*/

                    epgEntry.Country = eitEntry.Country;

                    tvStation.AddEPGEntry(epgEntry);

                    if (titleLogger != null)
                    {
                        logTitle(eitEntry.EventName, eitEntry, epgEntry, titleLogger);
                    }
                    if (descriptionLogger != null)
                    {
                        logTitle(eitEntry.Description, eitEntry, epgEntry, descriptionLogger);
                    }

                    if (RunParameters.Instance.DebugIDs.Contains("CATXREF"))
                    {
                        updateCategoryEntries(tvStation, eitEntry);
                    }
                }

                lastIndex = eitEntry.Index;
            }
        }
Example #10
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            try
            {
                transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                segmentLastSectionNumber = (int)byteData[lastIndex];
                lastIndex++;

                lastTableID = (int)byteData[lastIndex];
                lastIndex++;
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The FreeSat EIT section is short"));
            }

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                return;
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                FreeSatEntry freeSatEntry = new FreeSatEntry();
                freeSatEntry.Process(byteData, lastIndex);

                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                epgEntry.TransportStreamID = tvStation.TransportStreamID;
                epgEntry.ServiceID         = tvStation.ServiceID;
                epgEntry.EPGSource         = EPGSource.FreeSat;

                switch (freeSatEntry.ComponentTypeAudio)
                {
                case 3:
                    epgEntry.AudioQuality = "stereo";
                    break;

                case 5:
                    epgEntry.AudioQuality = "dolby digital";
                    break;

                default:
                    break;
                }

                if (freeSatEntry.ComponentTypeVideo > 9)
                {
                    epgEntry.VideoQuality = "HDTV";
                }

                epgEntry.Duration  = Utils.RoundTime(freeSatEntry.Duration);
                epgEntry.EventID   = freeSatEntry.EventID;
                epgEntry.EventName = freeSatEntry.EventName;

                if (freeSatEntry.ParentalRating > 11)
                {
                    epgEntry.ParentalRating = "AO";
                }
                else
                {
                    if (freeSatEntry.ParentalRating > 8)
                    {
                        epgEntry.ParentalRating = "PGR";
                    }
                    else
                    {
                        epgEntry.ParentalRating = "G";
                    }
                }

                setSeriesEpisode(epgEntry, freeSatEntry);

                epgEntry.RunningStatus    = freeSatEntry.RunningStatus;
                epgEntry.Scrambled        = freeSatEntry.Scrambled;
                epgEntry.ShortDescription = freeSatEntry.ShortDescription;
                epgEntry.StartTime        = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(freeSatEntry.StartTime));

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, freeSatEntry.ContentType, freeSatEntry.ContentSubType);

                tvStation.AddEPGEntry(epgEntry);

                if (titleLogger != null)
                {
                    logTitle(freeSatEntry.EventName, epgEntry, titleLogger);
                }
                if (descriptionLogger != null)
                {
                    logDescription(freeSatEntry.ShortDescription, epgEntry, descriptionLogger);
                }

                lastIndex = freeSatEntry.Index;
            }
        }