Exemplo n.º 1
0
        /// <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="extendedDescriptionLogger">A Logger instance for the extended program descriptions.</param>
        /// <param name="undefinedRecordLogger">A Logger instance for the undefined records.</param>
        public void ProcessChannelForEPG(TVStation station, Logger titleLogger, Logger descriptionLogger, Logger extendedDescriptionLogger, Logger undefinedRecordLogger)
        {
            bool first = true;
            DateTime expectedStartTime = new DateTime();

            foreach (OpenTVTitleData titleData in TitleData)
            {
                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = OriginalNetworkID;
                epgEntry.TransportStreamID = TransportStreamID;
                epgEntry.ServiceID = ServiceID;
                epgEntry.EventID = titleData.EventID;
                epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetAdjustedTime(titleData.StartTime));
                epgEntry.Duration = Utils.RoundTime(titleData.Duration);

                getEventName(epgEntry, titleData);
                OpenTVSummaryData summary = getShortDescription(epgEntry, titleData);

                getParentalRating(titleData, epgEntry);
                getAspectRatio(titleData, epgEntry);
                getVideoQuality(titleData, epgEntry);
                getAudioQuality(titleData, epgEntry);
                getSubTitles(titleData, epgEntry);
                getEventCategory(titleData, epgEntry);

                getSeasonEpisode(epgEntry);
                getSeriesLink(epgEntry, summary);

                getExtendedRatings(epgEntry);
                getDirector(epgEntry);
                getCast(epgEntry);
                getDate(epgEntry);

                getSubTitle(epgEntry);

                epgEntry.EPGSource = EPGSource.OpenTV;
                epgEntry.PID = titleData.PID;
                epgEntry.Table = titleData.Table;
                epgEntry.TimeStamp = titleData.TimeStamp;

                epgEntry.UnknownData = titleData.Flags;

                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)
                {
                    string seriesLink = "No ";
                    if (summary != null && summary.SeriesLink != -1)
                        seriesLink = "0x" + summary.SeriesLink.ToString("X");

                    titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                        " Cat ID " + titleData.CategoryID.ToString("000 ") +
                        " Flags " + Utils.ConvertToHex(titleData.Flags) +
                        " SLink " + seriesLink + " " +
                        epgEntry.StartTime.ToShortDateString() + " " +
                        epgEntry.StartTime.ToString("HH:mm") + " - " +
                        epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                        titleData.EventName);

                    if (RunParameters.Instance.DebugIDs.Contains("BITPATTERN"))
                        titleLogger.Write("Bit pattern: " + Utils.ConvertToBits(titleData.EventNameBytes));
                }

                if (descriptionLogger != null && summary != null)
                {
                    descriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                        epgEntry.StartTime.ToShortDateString() + " " +
                        epgEntry.StartTime.ToString("HH:mm") + " - " +
                        epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                        summary.ShortDescription);

                    if (RunParameters.Instance.DebugIDs.Contains("BITPATTERN"))
                        descriptionLogger.Write("Bit pattern: " + Utils.ConvertToBits(summary.ShortDescriptionBytes));
                }

                if (extendedDescriptionLogger != null && summary != null)
                {
                    string extendedDescription = summary.ExtendedDescription;
                    if (extendedDescription != null)
                        extendedDescriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                            epgEntry.StartTime.ToShortDateString() + " " +
                            epgEntry.StartTime.ToString("HH:mm") + " - " +
                            epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                            extendedDescription);
                }

                if (undefinedRecordLogger != null)
                {
                    Collection<OpenTVRecordBase> undefinedTitleRecords = titleData.UndefinedRecords;

                    if (undefinedTitleRecords != null)
                    {
                        foreach (OpenTVRecordBase record in undefinedTitleRecords)
                        {
                            if (record.Data != null)
                                undefinedRecordLogger.Write("Title records: " + epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                    epgEntry.StartTime.ToShortDateString() + " " +
                                    epgEntry.StartTime.ToString("HH:mm") + " - " +
                                    epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                    titleData.EventName +
                                    " Tag: " + record.Tag.ToString("X") +
                                    " Data: " + Utils.ConvertToHex(record.Data));
                            else
                                undefinedRecordLogger.Write("Title records: " + epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                    epgEntry.StartTime.ToShortDateString() + " " +
                                    epgEntry.StartTime.ToString("HH:mm") + " - " +
                                    epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                    titleData.EventName +
                                    " Tag: 0x" + record.Tag.ToString("X") +
                                    " Data: No data");
                        }
                    }

                    if (summary != null)
                    {
                        Collection<OpenTVRecordBase> undefinedSummaryRecords = summary.UndefinedRecords;

                        if (undefinedSummaryRecords != null)
                        {
                            foreach (OpenTVRecordBase record in undefinedSummaryRecords)
                            {
                                if (record.Data != null)
                                    undefinedRecordLogger.Write("Summary records: " + epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                        epgEntry.StartTime.ToShortDateString() + " " +
                                        epgEntry.StartTime.ToString("HH:mm") + " - " +
                                        epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") +
                                        " Tag: " + record.Tag.ToString("X") +
                                        " Data: " + Utils.ConvertToHex(record.Data));
                                else
                                    undefinedRecordLogger.Write("Summary records: " + epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                        epgEntry.StartTime.ToShortDateString() + " " +
                                        epgEntry.StartTime.ToString("HH:mm") + " - " +
                                        epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") +
                                        " Tag: ox" + record.Tag.ToString("X") +
                                        " Data: No data");
                            }
                        }
                    }
                }

                if (RunParameters.Instance.DebugIDs.Contains("CATXREF"))
                    updateCategoryEntries(OriginalNetworkID, TransportStreamID, ServiceID, epgEntry.StartTime, epgEntry.EventName, titleData.CategoryID);

                if (!RunParameters.Instance.Options.Contains("ACCEPTBREAKS"))
                {
                    if (epgEntry.StartTime.Second != 0)
                    {
                        if (titleLogger != null)
                            titleLogger.Write("** Suspect Start Time **");
                    }
                }
            }

            foreach (OpenTVTitleData titleData in SuspectTimeTitleData)
            {
                if (titleLogger != null)
                    titleLogger.Write("** Suspect time: " + titleData.StartTime + " " + titleData.EventName);
            }
        }
Exemplo n.º 2
0
        /// <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 **");
                    }
                }
            }
        }