Ejemplo n.º 1
0
        private void getParentalRating(EPGEntry epgEntry, BellTVEntry entry)
        {
            epgEntry.ParentalRating       = ParentalRating.FindRating("USA", "DISHNETWORK", entry.ParentalRating.ToString());
            epgEntry.MpaaParentalRating   = ParentalRating.FindMpaaRating("USA", "DISHNETWORK", entry.ParentalRating.ToString());
            epgEntry.ParentalRatingSystem = ParentalRating.FindSystem("USA", "DISHNETWORK", entry.ParentalRating.ToString());

            /*switch (entry.ParentalRating)
             * {
             *  case 0:
             *      return (null);
             *  case 1:
             *      return ("G");
             *  case 2:
             *      return ("PG");
             *  case 3:
             *      return ("PG-13");
             *  case 4:
             *      return ("R");
             *  case 5:
             *      return ("NR/AO");
             *  case 6:
             *      return (null);
             *  case 7:
             *      return ("NC-17");
             *  default:
             *      return (null);
             * }*/
        }
Ejemplo n.º 2
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;
            }
        }