private string getStarRating(DishNetworkEntry entry) { switch (entry.StarRating) { case 0: return(null); case 1: return("*"); case 2: return("*+"); case 3: return("**"); case 4: return("**+"); case 5: return("***"); case 6: return("***+"); case 7: return("****"); default: return(null); } }
private void getParentalRating(EPGEntry epgEntry, DishNetworkEntry 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; * 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); * }*/ }
private string getStarRating(DishNetworkEntry entry) { switch (entry.StarRating) { case 0: return (null); case 1: return ("*"); case 2: return ("*+"); case 3: return ("**"); case 4: return ("**+"); case 5: return ("***"); case 6: return ("***+"); case 7: return ("****"); default: return (null); } }
private void getParentalRating(EPGEntry epgEntry, DishNetworkEntry 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; 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); }*/ }
/// <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 Dish Network 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) { DishNetworkEntry dishNetworkEntry = new DishNetworkEntry(); dishNetworkEntry.Process(byteData, lastIndex, mpeg2Header.TableID); EPGEntry epgEntry = new EPGEntry(); epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID; epgEntry.TransportStreamID = tvStation.TransportStreamID; epgEntry.ServiceID = tvStation.ServiceID; epgEntry.EPGSource = EPGSource.DishNetwork; if (dishNetworkEntry.HighDefinition) epgEntry.VideoQuality = "HDTV"; if (dishNetworkEntry.ClosedCaptions) epgEntry.SubTitles = "teletext"; if (dishNetworkEntry.Stereo) epgEntry.AudioQuality = "stereo"; epgEntry.Duration = Utils.RoundTime(dishNetworkEntry.Duration); epgEntry.EventID = dishNetworkEntry.EventID; epgEntry.EventName = dishNetworkEntry.EventName; getParentalRating(epgEntry, dishNetworkEntry); epgEntry.RunningStatus = dishNetworkEntry.RunningStatus; epgEntry.Scrambled = dishNetworkEntry.Scrambled; epgEntry.ShortDescription = dishNetworkEntry.ShortDescription; if (dishNetworkEntry.SubTitle != dishNetworkEntry.EventName) epgEntry.EventSubTitle = dishNetworkEntry.SubTitle; epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(dishNetworkEntry.StartTime)); epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, dishNetworkEntry.ContentType, dishNetworkEntry.ContentSubType); epgEntry.StarRating = getStarRating(dishNetworkEntry); epgEntry.Date = dishNetworkEntry.Date; epgEntry.Cast = dishNetworkEntry.Cast; getSeriesEpisode(epgEntry, dishNetworkEntry.Series, dishNetworkEntry.Episode); epgEntry.HasGraphicLanguage = dishNetworkEntry.HasStrongLanguage; epgEntry.HasStrongSexualContent = dishNetworkEntry.HasSexualContent; epgEntry.HasGraphicViolence = dishNetworkEntry.HasViolence; epgEntry.HasNudity = dishNetworkEntry.HasNudity; epgEntry.PreviousPlayDate = dishNetworkEntry.OriginalAirDate; tvStation.AddEPGEntry(epgEntry); if (titleLogger != null) logTitle(dishNetworkEntry.EventName, epgEntry, titleLogger); if (descriptionLogger != null) { if (!RunParameters.Instance.DebugIDs.Contains("LOGORIGINAL")) logDescription(dishNetworkEntry.ShortDescription, epgEntry, descriptionLogger); else logDescription(dishNetworkEntry.OriginalDescription, epgEntry, descriptionLogger); } lastIndex = dishNetworkEntry.Index; } }
/// <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 Dish Network 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) { DishNetworkEntry dishNetworkEntry = new DishNetworkEntry(); dishNetworkEntry.Process(byteData, lastIndex, mpeg2Header.TableID); EPGEntry epgEntry = new EPGEntry(); epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID; epgEntry.TransportStreamID = tvStation.TransportStreamID; epgEntry.ServiceID = tvStation.ServiceID; epgEntry.EPGSource = EPGSource.DishNetwork; if (dishNetworkEntry.HighDefinition) { epgEntry.VideoQuality = "HDTV"; } if (dishNetworkEntry.ClosedCaptions) { epgEntry.SubTitles = "teletext"; } if (dishNetworkEntry.Stereo) { epgEntry.AudioQuality = "stereo"; } epgEntry.Duration = Utils.RoundTime(dishNetworkEntry.Duration); epgEntry.EventID = dishNetworkEntry.EventID; epgEntry.EventName = dishNetworkEntry.EventName; getParentalRating(epgEntry, dishNetworkEntry); epgEntry.RunningStatus = dishNetworkEntry.RunningStatus; epgEntry.Scrambled = dishNetworkEntry.Scrambled; epgEntry.ShortDescription = dishNetworkEntry.ShortDescription; if (dishNetworkEntry.SubTitle != dishNetworkEntry.EventName) { epgEntry.EventSubTitle = dishNetworkEntry.SubTitle; } epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(dishNetworkEntry.StartTime)); epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, dishNetworkEntry.ContentType, dishNetworkEntry.ContentSubType); epgEntry.StarRating = getStarRating(dishNetworkEntry); epgEntry.Date = dishNetworkEntry.Date; epgEntry.Cast = dishNetworkEntry.Cast; getSeriesEpisode(epgEntry, dishNetworkEntry.Series, dishNetworkEntry.Episode); epgEntry.HasGraphicLanguage = dishNetworkEntry.HasStrongLanguage; epgEntry.HasStrongSexualContent = dishNetworkEntry.HasSexualContent; epgEntry.HasGraphicViolence = dishNetworkEntry.HasViolence; epgEntry.HasNudity = dishNetworkEntry.HasNudity; epgEntry.PreviousPlayDate = dishNetworkEntry.OriginalAirDate; tvStation.AddEPGEntry(epgEntry); if (titleLogger != null) { logTitle(dishNetworkEntry.EventName, epgEntry, titleLogger); } if (descriptionLogger != null) { if (!RunParameters.Instance.DebugIDs.Contains("LOGORIGINAL")) { logDescription(dishNetworkEntry.ShortDescription, epgEntry, descriptionLogger); } else { logDescription(dishNetworkEntry.OriginalDescription, epgEntry, descriptionLogger); } } lastIndex = dishNetworkEntry.Index; } }