예제 #1
0
        private static bool checkNZLTimes(EPGEntry currentEntry, EPGEntry nextEntry)
        {
            if (!currentEntry.EndsAtMidnight)
            {
                return(false);
            }

            if (!nextEntry.StartsAtMidnight)
            {
                return(false);
            }

            if (currentEntry.StartTime + currentEntry.Duration != nextEntry.StartTime)
            {
                return(false);
            }

            if (nextEntry.Duration > new TimeSpan(3, 0, 0))
            {
                return(false);
            }

            Logger.Instance.Write("Combining " + currentEntry.ScheduleDescription + " with " + nextEntry.ScheduleDescription);
            currentEntry.Duration = currentEntry.Duration + nextEntry.Duration;

            return(true);
        }
예제 #2
0
        private static void processStationEPG(XmlWriter xmlWriter, TVStation tvStation)
        {
            Regex whitespace = new Regex(@"\s+");

            string channelNumber;

            if (tvStation.ChannelID == null)
            {
                if (!RunParameters.Instance.Options.Contains("USECHANNELID"))
                {
                    channelNumber = tvStation.ServiceID.ToString();
                }
                else
                {
                    if (tvStation.LogicalChannelNumber != -1)
                    {
                        channelNumber = tvStation.LogicalChannelNumber.ToString();
                    }
                    else
                    {
                        channelNumber = tvStation.ServiceID.ToString();
                    }
                }
            }
            else
            {
                channelNumber = tvStation.ChannelID;
            }

            for (int index = 0; index < tvStation.EPGCollection.Count; index++)
            {
                EPGEntry epgEntry = tvStation.EPGCollection[index];
                processEPGEntry(xmlWriter, channelNumber, epgEntry);
            }
        }
예제 #3
0
        private static string getStartTime(EPGEntry epgEntry)
        {
            DateTime gmtStartTime = TimeZoneInfo.ConvertTimeToUtc(epgEntry.StartTime);
            TimeSpan timeSpan     = gmtStartTime - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            UInt32   seconds      = Convert.ToUInt32(Math.Abs(timeSpan.TotalSeconds));

            return(seconds.ToString());
        }
예제 #4
0
        /// <summary>
        /// Create a copy of this instance.
        /// </summary>
        /// <returns>The replicated instance.</returns>
        public EPGEntry Clone()
        {
            EPGEntry newEntry = new EPGEntry();

            newEntry.originalNetworkID = originalNetworkID;
            newEntry.transportStreamID = transportStreamID;
            newEntry.serviceID         = serviceID;
            newEntry.versionNumber     = versionNumber;

            newEntry.eventID              = eventID;
            newEntry.eventName            = eventName;
            newEntry.eventSubTitle        = eventSubTitle;
            newEntry.startTime            = startTime;
            newEntry.duration             = duration;
            newEntry.runningStatus        = runningStatus;
            newEntry.scrambled            = scrambled;
            newEntry.shortDescription     = shortDescription;
            newEntry.extendedDescription  = extendedDescription;
            newEntry.subTitles            = subTitles;
            newEntry.parentalRating       = parentalRating;
            newEntry.mpaaParentalRating   = mpaaParentalRating;
            newEntry.parentalRatingSystem = parentalRatingSystem;
            newEntry.eventCategory        = eventCategory;
            newEntry.videoQuality         = videoQuality;
            newEntry.audioQuality         = audioQuality;
            newEntry.aspectRatio          = aspectRatio;
            newEntry.series             = series;
            newEntry.episode            = episode;
            newEntry.partNumber         = partNumber;
            newEntry.episodeSystemType  = episodeSystemType;
            newEntry.episodeSystemParts = episodeSystemParts;
            newEntry.seasonNumber       = seasonNumber;
            newEntry.episodeNumber      = episodeNumber;
            newEntry.cast             = cast;
            newEntry.directors        = directors;
            newEntry.date             = date;
            newEntry.starRating       = starRating;
            newEntry.previousPlayDate = previousPlayDate;
            newEntry.country          = country;

            newEntry.hasAdult               = hasAdult;
            newEntry.hasGraphicLanguage     = hasGraphicLanguage;
            newEntry.hasNudity              = hasNudity;
            newEntry.hasStrongSexualContent = hasStrongSexualContent;

            newEntry.pid       = pid;
            newEntry.table     = table;
            newEntry.timeStamp = timeStamp;

            newEntry.unknownData = unknownData;

            newEntry.epgSource = epgSource;

            return(newEntry);
        }
예제 #5
0
        private static bool checkAUSTimes(EPGEntry currentEntry, EPGEntry nextEntry)
        {
            if (!nextEntry.StartsAtMidnight)
            {
                return(false);
            }

            if (currentEntry.StartTime + currentEntry.Duration != nextEntry.StartTime + nextEntry.Duration)
            {
                return(false);
            }

            Logger.Instance.Write("Combining " + currentEntry.ScheduleDescription + " with " + nextEntry.ScheduleDescription);

            return(true);
        }
예제 #6
0
        private static void processStationEPG(XmlWriter xmlWriter, TVStation tvStation)
        {
            xmlWriter.WriteStartElement("dvblink_epg");

            for (int index = 0; index < tvStation.EPGCollection.Count; index++)
            {
                EPGEntry epgEntry = tvStation.EPGCollection[index];

                if (TuningFrequency.HasMHEG5Frequency)
                {
                    checkMidnightBreak(tvStation, epgEntry, index);
                }

                processEPGEntry(xmlWriter, epgEntry);
            }

            xmlWriter.WriteEndElement();
        }
예제 #7
0
        private static void processSeries(XmlWriter xmlWriter, EPGEntry epgEntry)
        {
            if (epgEntry.EpisodeSystemType == null || epgEntry.Series == null)
            {
                return;
            }

            string seriesLink = getSeriesLink(epgEntry);

            foreach (string oldSeriesLink in series)
            {
                if (oldSeriesLink == seriesLink)
                {
                    xmlWriter.WriteAttributeString("isSeries", "1");
                    xmlWriter.WriteAttributeString("series", "si" + (series.IndexOf(oldSeriesLink) + 1).ToString());
                    return;
                }
            }
        }
예제 #8
0
        private static void checkMidnightBreak(TVStation tvStation, EPGEntry currentEntry, int index)
        {
            if (index == tvStation.EPGCollection.Count - 1)
            {
                return;
            }

            EPGEntry nextEntry = tvStation.EPGCollection[index + 1];

            if (currentEntry.EventName != nextEntry.EventName)
            {
                return;
            }

            bool combined = false;

            if (RunParameters.Instance.CountryCode == null)
            {
                combined = checkNZLTimes(currentEntry, nextEntry);
            }
            else
            {
                switch (RunParameters.Instance.CountryCode)
                {
                case "NZL":
                    combined = checkNZLTimes(currentEntry, nextEntry);
                    break;

                case "AUS":
                    combined = checkAUSTimes(currentEntry, nextEntry);
                    break;

                default:
                    break;
                }
            }

            if (combined)
            {
                tvStation.EPGCollection.RemoveAt(index + 1);
            }
        }
예제 #9
0
        /// <summary>
        /// Add an EPG entry for the station.
        /// </summary>
        /// <param name="newEntry">The EPG entry.</param>
        /// <returns>True if it was added; false if it replaced an existing entry.</returns>
        public bool AddEPGEntry(EPGEntry newEntry)
        {
            if (newEntry == null)
            {
                throw (new ArgumentException("The new entry cannot be null", "newEntry"));
            }

            foreach (EPGEntry oldEntry in EPGCollection)
            {
                if (newEntry.StartTime == oldEntry.StartTime)
                {
                    if (newEntry.EventName != null)
                    {
                        EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry);
                        EPGCollection.Remove(oldEntry);
                    }
                    return(false);
                }
                else
                {
                    if (newEntry.StartTime > oldEntry.StartTime && (newEntry.StartTime + newEntry.Duration) <= (oldEntry.StartTime + oldEntry.Duration))
                    {
                        return(false);
                    }

                    if (newEntry.StartTime < oldEntry.StartTime)
                    {
                        EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry);
                        return(true);
                    }
                }
            }

            EPGCollection.Add(newEntry);

            return(true);
        }
예제 #10
0
        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);
        }
예제 #11
0
        internal bool AddEPGEntry(EPGEntry newEntry)
        {
            foreach (EPGEntry oldEntry in EPGCollection)
            {
                if (newEntry.StartTime == oldEntry.StartTime)
                {
                    EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry);
                    EPGCollection.Remove(oldEntry);
                    return (false);
                }
                else
                {
                    if (newEntry.StartTime > oldEntry.StartTime && (newEntry.StartTime + newEntry.Duration) <= (oldEntry.StartTime + oldEntry.Duration))
                        return (false);

                    if (newEntry.StartTime < oldEntry.StartTime)
                    {
                        EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry);
                        return (true);
                    }
                }
            }

            EPGCollection.Add(newEntry);

            return (true);
        }
예제 #12
0
        private void processCRIDNumeric(EPGEntry epgEntry, string seriesID, string seasonID, string episodeID)
        {
            epgEntry.EpisodeSystemType = "xmltv_ns";
            epgEntry.EpisodeSystemParts = 3;

            if (seriesID != null && seasonID != null && episodeID != null)
            {
                epgEntry.Series = ((uint)seriesID.GetHashCode()).ToString();
                epgEntry.Episode = ((uint)seasonID.GetHashCode()).ToString();
                epgEntry.PartNumber = ((uint)episodeID.GetHashCode()).ToString();
                return;
            }

            if (seriesID != null && seasonID != null)
            {
                epgEntry.Series = ((uint)seriesID.GetHashCode()).ToString();
                epgEntry.Episode = ((uint)seasonID.GetHashCode()).ToString();
                return;
            }

            if (seriesID != null)
            {
                if (episodeID != null)
                {
                    epgEntry.Series = ((uint)seriesID.GetHashCode()).ToString();
                    epgEntry.Episode = ((uint)episodeID.GetHashCode()).ToString();
                }
                else
                    epgEntry.Series = ((uint)seriesID.GetHashCode()).ToString();

                return;
            }

            if (seasonID != null)
            {
                if (episodeID != null)
                {
                    epgEntry.Series = ((uint)seasonID.GetHashCode()).ToString();
                    epgEntry.Episode = ((uint)episodeID.GetHashCode()).ToString();
                }
                else
                    epgEntry.Series = ((uint)seasonID.GetHashCode()).ToString();

                return;
            }

            epgEntry.Episode = ((uint)episodeID.GetHashCode()).ToString();
        }
예제 #13
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;
            }
        }
예제 #14
0
        private void getParentalRating(OpenTVTitleData titleData, EPGEntry epgEntry)
        {
            if (titleData.Flags == null || titleData.Flags.Length < 2)
                return;

            epgEntry.ParentalRating = ParentalRating.FindRating(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString());
            epgEntry.MpaaParentalRating = ParentalRating.FindMpaaRating(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString());
            epgEntry.ParentalRatingSystem = ParentalRating.FindSystem(RunParameters.Instance.CountryCode, "OPENTV", (titleData.Flags[1] & 0x0f).ToString());
        }
예제 #15
0
        private static void processEPGEntry(XmlWriter xmlWriter, string channelNumber, EPGEntry epgEntry)
        {
            Regex whitespace = new Regex(@"\s+");

            xmlWriter.WriteStartElement("programme");

            xmlWriter.WriteAttributeString("start", epgEntry.StartTime.ToString("yyyyMMddHHmmss zzz").Replace(":", ""));
            xmlWriter.WriteAttributeString("stop", (epgEntry.StartTime + epgEntry.Duration).ToString("yyyyMMddHHmmss zzz").Replace(":", ""));

            xmlWriter.WriteAttributeString("channel", channelNumber);

            if (epgEntry.EventName != null)
            {
                xmlWriter.WriteElementString("title", TextTranslator.GetTranslatedText(
                                                 RunParameters.Instance.InputLanguage,
                                                 RunParameters.Instance.OutputLanguage,
                                                 whitespace.Replace(epgEntry.EventName.Trim(), " ")));
            }
            else
            {
                xmlWriter.WriteElementString("title", TextTranslator.GetTranslatedText(
                                                 RunParameters.Instance.InputLanguage,
                                                 RunParameters.Instance.OutputLanguage, "No Title"));
            }

            if (!RunParameters.Instance.Options.Contains("USEDVBVIEWER"))
            {
                if (epgEntry.EventSubTitle != null)
                {
                    xmlWriter.WriteElementString("sub-title", TextTranslator.GetTranslatedText(
                                                     RunParameters.Instance.InputLanguage,
                                                     RunParameters.Instance.OutputLanguage,
                                                     whitespace.Replace(epgEntry.EventSubTitle.Trim(), " ")));
                }

                if (epgEntry.ShortDescription != null)
                {
                    xmlWriter.WriteElementString("desc", TextTranslator.GetTranslatedText(
                                                     RunParameters.Instance.InputLanguage,
                                                     RunParameters.Instance.OutputLanguage,
                                                     whitespace.Replace(epgEntry.ShortDescription.Trim(), " ")));
                }
                else
                {
                    if (epgEntry.EventName != null)
                    {
                        xmlWriter.WriteElementString("desc", TextTranslator.GetTranslatedText(
                                                         RunParameters.Instance.InputLanguage,
                                                         RunParameters.Instance.OutputLanguage,
                                                         whitespace.Replace(epgEntry.EventName.Trim(), " ")));
                    }
                    else
                    {
                        xmlWriter.WriteElementString("desc", TextTranslator.GetTranslatedText(
                                                         RunParameters.Instance.InputLanguage,
                                                         RunParameters.Instance.OutputLanguage,
                                                         "No Description"));
                    }
                }
            }
            else
            {
                if (epgEntry.ShortDescription != null)
                {
                    xmlWriter.WriteElementString("sub-title", whitespace.Replace(epgEntry.ShortDescription.Trim(), " "));
                }
                else
                {
                    if (epgEntry.EventName != null)
                    {
                        xmlWriter.WriteElementString("sub-title", whitespace.Replace(epgEntry.EventName.Trim(), " "));
                    }
                    else
                    {
                        xmlWriter.WriteElementString("sub-title", "No Description");
                    }
                }
            }

            if (epgEntry.EventCategory != null)
            {
                string[] categories = epgEntry.EventCategory.Split(new char[] { ',' });

                foreach (string category in categories)
                {
                    xmlWriter.WriteElementString("category", category);
                }
            }

            if (epgEntry.ParentalRating != null)
            {
                xmlWriter.WriteStartElement("rating");
                if (epgEntry.ParentalRatingSystem != null)
                {
                    xmlWriter.WriteAttributeString("system", epgEntry.ParentalRatingSystem);
                }
                xmlWriter.WriteElementString("value", epgEntry.ParentalRating);
                xmlWriter.WriteEndElement();
            }

            if (epgEntry.StarRating != null)
            {
                xmlWriter.WriteStartElement("star-rating");
                xmlWriter.WriteElementString("value", epgEntry.StarRating);
                xmlWriter.WriteEndElement();
            }

            if (epgEntry.AspectRatio != null || epgEntry.VideoQuality != null)
            {
                xmlWriter.WriteStartElement("video");
                if (epgEntry.AspectRatio != null)
                {
                    xmlWriter.WriteElementString("aspect", epgEntry.AspectRatio);
                }
                if (epgEntry.VideoQuality != null)
                {
                    xmlWriter.WriteElementString("quality", epgEntry.VideoQuality);
                }
                xmlWriter.WriteEndElement();
            }

            if (epgEntry.AudioQuality != null)
            {
                xmlWriter.WriteStartElement("audio");
                xmlWriter.WriteElementString("stereo", epgEntry.AudioQuality);
                xmlWriter.WriteEndElement();
            }

            if (epgEntry.SubTitles != null)
            {
                xmlWriter.WriteStartElement("subtitles");
                xmlWriter.WriteAttributeString("type", epgEntry.SubTitles);
                xmlWriter.WriteEndElement();
            }

            if (epgEntry.EpisodeSystemType != null)
            {
                string series;
                if (epgEntry.Series != null)
                {
                    series = epgEntry.Series;
                }
                else
                {
                    series = "";
                }

                string episode;
                if (epgEntry.Episode != null)
                {
                    episode = epgEntry.Episode;
                }
                else
                {
                    episode = "";
                }

                string partNumber;
                if (epgEntry.PartNumber != null)
                {
                    partNumber = epgEntry.PartNumber;
                }
                else
                {
                    partNumber = "";
                }

                xmlWriter.WriteStartElement("episode-num");
                xmlWriter.WriteAttributeString("system", epgEntry.EpisodeSystemType);

                if (epgEntry.EpisodeSystemParts != 2)
                {
                    xmlWriter.WriteString(series + " . " + episode + " . " + partNumber);
                }
                else
                {
                    xmlWriter.WriteString(series + " . " + episode);
                }

                xmlWriter.WriteEndElement();
            }

            if (epgEntry.PreviousPlayDate != DateTime.MinValue)
            {
                xmlWriter.WriteStartElement("previously-shown");
                xmlWriter.WriteAttributeString("start", epgEntry.PreviousPlayDate.ToString("yyyyMMddHHmmss zzz").Replace(":", ""));
                xmlWriter.WriteEndElement();
            }

            if ((epgEntry.Directors != null && epgEntry.Directors.Count != 0) || (epgEntry.Cast != null && epgEntry.Cast.Count != 0))
            {
                xmlWriter.WriteStartElement("credits");

                if (epgEntry.Directors != null)
                {
                    foreach (string director in epgEntry.Directors)
                    {
                        xmlWriter.WriteElementString("director", director.Trim());
                    }
                }

                if (epgEntry.Cast != null)
                {
                    foreach (string castMember in epgEntry.Cast)
                    {
                        xmlWriter.WriteElementString("actor", castMember.Trim());
                    }
                }

                xmlWriter.WriteEndElement();
            }

            if (epgEntry.Date != null)
            {
                xmlWriter.WriteElementString("date", epgEntry.Date);
            }

            if (epgEntry.Country != null)
            {
                xmlWriter.WriteElementString("country", epgEntry.Country);
            }

            xmlWriter.WriteEndElement();
        }
예제 #16
0
        private static void processEPGEntry(XmlWriter xmlWriter, EPGEntry epgEntry)
        {
            Regex whitespace = new Regex(@"\s+");

            xmlWriter.WriteStartElement("program");

            if (epgEntry.EventName != null)
            {
                xmlWriter.WriteAttributeString("name", whitespace.Replace(epgEntry.EventName.Trim(), " "));
            }
            else
            {
                xmlWriter.WriteAttributeString("name", "No Title");
            }

            /*TimeSpan timeSpan = epgEntry.StartTime - new DateTime(1970, 1, 1, 0, 0, 0, 0);
             * UInt32 seconds = Convert.ToUInt32(Math.Abs(timeSpan.TotalSeconds));*/
            xmlWriter.WriteElementString("start_time", getStartTime(epgEntry));
            xmlWriter.WriteElementString("duration", epgEntry.Duration.TotalSeconds.ToString());

            if (epgEntry.EventSubTitle != null)
            {
                xmlWriter.WriteElementString("subname", whitespace.Replace(epgEntry.EventSubTitle.Trim(), " "));
            }

            if (epgEntry.ShortDescription != null)
            {
                xmlWriter.WriteElementString("short_desc", whitespace.Replace(epgEntry.ShortDescription.Trim(), " "));
            }
            else
            {
                if (epgEntry.EventName != null)
                {
                    xmlWriter.WriteElementString("short_desc", whitespace.Replace(epgEntry.EventName.Trim(), " "));
                }
                else
                {
                    xmlWriter.WriteElementString("short_desc", "No Description");
                }
            }

            if (epgEntry.EventCategory != null)
            {
                xmlWriter.WriteElementString("categories", "");

                string[] categoryParts = epgEntry.EventCategory.Split(new char[] { ',' });

                foreach (string categoryPart in categoryParts)
                {
                    xmlWriter.WriteElementString("cat_" + categoryPart.Trim(), "");
                }
            }

            /* if (epgEntry.ParentalRating != null)
             * {
             *   xmlWriter.WriteStartElement("rating");
             *   if (epgEntry.ParentalRatingSystem != null)
             *       xmlWriter.WriteAttributeString("system", epgEntry.ParentalRatingSystem);
             *   xmlWriter.WriteElementString("value", epgEntry.ParentalRating);
             *   xmlWriter.WriteEndElement();
             * }*/

            if (epgEntry.VideoQuality != null && epgEntry.VideoQuality.ToLowerInvariant() == "hdtv")
            {
                xmlWriter.WriteElementString("hdtv", string.Empty);
            }

            if (epgEntry.EpisodeSystemType != null && epgEntry.EpisodeSystemType == "xmltv_ns")
            {
                if (epgEntry.Series != null)
                {
                    xmlWriter.WriteElementString("season_num", epgEntry.Series);
                }
                if (epgEntry.Episode != null && epgEntry.Episode != "0")
                {
                    xmlWriter.WriteElementString("episode_num", epgEntry.Episode);
                }
            }

            if (epgEntry.Directors != null)
            {
                StringBuilder directorString = new StringBuilder();

                foreach (string director in epgEntry.Directors)
                {
                    if (directorString.Length != 0)
                    {
                        directorString.Append("/");
                    }
                    directorString.Append(director.Trim());
                }

                xmlWriter.WriteElementString("directors", directorString.ToString());
            }

            if (epgEntry.Cast != null)
            {
                StringBuilder castString = new StringBuilder();

                foreach (string castMember in epgEntry.Cast)
                {
                    if (castString.Length != 0)
                    {
                        castString.Append("/");
                    }
                    castString.Append(castMember.Trim());
                }

                xmlWriter.WriteElementString("actors", castString.ToString());
            }

            if (epgEntry.Date != null)
            {
                xmlWriter.WriteElementString("year", epgEntry.Date);
            }

            if (epgEntry.PreviousPlayDate != DateTime.MinValue)
            {
                xmlWriter.WriteElementString("repeat", string.Empty);
            }

            xmlWriter.WriteEndElement();
        }
예제 #17
0
 private static string getSeriesLink(EPGEntry epgEntry)
 {
     return(epgEntry.OriginalNetworkID + "-" + epgEntry.TransportStreamID + "-" + epgEntry.ServiceID + "-" + epgEntry.EventName + "-" + epgEntry.Series);
 }
예제 #18
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);
            }*/
        }
예제 #19
0
        private void getSeriesLink(EPGEntry epgEntry, OpenTVSummaryData summaryData)
        {
            if (summaryData == null || summaryData.SeriesLink == -1)
                return;

            if (RunParameters.Instance.Options.Contains("USEBSEPG"))
            {
                getSeriesLinkBSEPG(epgEntry, summaryData.SeriesLink);
                return;
            }

            if (epgEntry.EpisodeSystemType != null)
                return;

            epgEntry.Series = summaryData.SeriesLink.ToString();
            epgEntry.EpisodeSystemType = "xmltv_ns";
            epgEntry.EpisodeSystemParts = 3;
        }
예제 #20
0
 private void logDescription(string description, EPGEntry epgEntry, Logger logger)
 {
     logger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
         epgEntry.StartTime.ToShortDateString() + " " +
         epgEntry.StartTime.ToString("HH:mm") + " - " +
         epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
         description);
 }
예제 #21
0
        private OpenTVSummaryData getShortDescription(EPGEntry epgEntry, OpenTVTitleData titleData)
        {
            OpenTVSummaryData summary = findSummary(titleData.EventID);
            if (summary != null)
                epgEntry.ShortDescription = summary.ShortDescription;
            else
                epgEntry.ShortDescription = "No Synopsis Available";

            return (summary);
        }
예제 #22
0
        private void getExtendedRatings(EPGEntry epgEntry)
        {
            if (RunParameters.Instance.CountryCode != "AUS")
                return;

            int startIndex = epgEntry.ShortDescription.IndexOf("(");

            while (startIndex != -1)
            {
                if (epgEntry.ShortDescription[startIndex + 1] > '9')
                {
                    int endIndex = epgEntry.ShortDescription.IndexOf(")", startIndex);
                    if (endIndex != -1)
                    {
                        string ratingString = epgEntry.ShortDescription.Substring(startIndex + 1, endIndex - (startIndex + 1));
                        Collection<string> ratings = new Collection<string>(ratingString.Split(new char[] { ',' }));

                        bool isRatingField = true;

                        foreach (string rating in ratings)
                        {
                            if (rating.Length != 1)
                                isRatingField = false;
                        }

                        if (isRatingField)
                        {
                            epgEntry.HasGraphicViolence = ratings.Contains("v");
                            epgEntry.HasGraphicLanguage = ratings.Contains("l");
                            epgEntry.HasStrongSexualContent = ratings.Contains("s");
                            epgEntry.HasAdult = ratings.Contains("a");
                            epgEntry.HasNudity = ratings.Contains("n");

                            if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA"))
                                epgEntry.ShortDescription = epgEntry.ShortDescription.Remove(startIndex, endIndex - startIndex + 1).Trim();

                            return;
                        }
                        else
                            startIndex = epgEntry.ShortDescription.IndexOf("(", startIndex + 1);
                    }
                }
                else
                    startIndex = epgEntry.ShortDescription.IndexOf("(", startIndex + 1);
            }
        }
예제 #23
0
        private void getSkyAUSSeasonEpisode(EPGEntry epgEntry)
        {
            int index1 = epgEntry.ShortDescription.IndexOf(" Ep");
            if (index1 == -1)
                return;
            if (index1 + 3 == epgEntry.ShortDescription.Length)
                return;
            if (index1 < 2)
                return;
            if (epgEntry.ShortDescription[index1 + 3] < '0' || epgEntry.ShortDescription[index1 + 3] > '9')
                return;
            if (epgEntry.ShortDescription[index1 - 1] != ',')
                return;
            if (epgEntry.ShortDescription[index1 - 2] < '0' || epgEntry.ShortDescription[index1 - 2] > '9')
                return;

            int index2 = index1 - 2;

            while (epgEntry.ShortDescription[index2] != 'S')
                index2--;

            int index3 = index1 + 3;

            while (index3 < epgEntry.ShortDescription.Length && epgEntry.ShortDescription[index3] >= '0' && epgEntry.ShortDescription[index3] <= '9')
                index3++;

            int series = 0;
            int index4 = index2 + 1;
            while (epgEntry.ShortDescription[index4] != ',')
            {
                series = (series * 10) + (epgEntry.ShortDescription[index4] - '0');
                index4++;
            }

            int episode = 0;
            int index5 = index1 + 3;
            while (index5 < index3)
            {
                episode = (episode * 10) + (epgEntry.ShortDescription[index5] - '0');
                index5++;
            }

            if (RunParameters.Instance.Options.Contains("USEBSEPG"))
            {
                epgEntry.Series = "SE-" + series.ToString();
                epgEntry.Episode = "EP-" + episode.ToString();
                epgEntry.EpisodeSystemType = "bsepg-epid";
                epgEntry.EpisodeSystemParts = 2;
            }
            else
            {
                epgEntry.Series = series.ToString();
                epgEntry.Episode = episode.ToString();
                epgEntry.EpisodeSystemType = "xmltv_ns";
                epgEntry.EpisodeSystemParts = 3;
            }

            epgEntry.SeasonNumber = series;
            epgEntry.EpisodeNumber = episode;

            if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA"))
                epgEntry.ShortDescription = epgEntry.ShortDescription.Remove(index2, index5 - index2 + 1).Trim();
        }
예제 #24
0
 private void getSeasonEpisode(EPGEntry epgEntry)
 {
     switch (RunParameters.Instance.CountryCode)
     {
         case "AUS":
             getSkyAUSSeasonEpisode(epgEntry);
             break;
         case "GBR":
             getSkyGBRSeasonEpisode(epgEntry);
             break;
         default:
             break;
     }
 }
예제 #25
0
        private static string processEpisode(XmlWriter xmlWriter, Collection <string> series, EPGEntry epgEntry)
        {
            if (epgEntry.EpisodeSystemType == null || epgEntry.Series == null)
            {
                return(null);
            }

            string newSeriesLink = getSeriesLink(epgEntry);

            foreach (string oldSeriesLink in series)
            {
                if (oldSeriesLink == newSeriesLink)
                {
                    return(null);
                }
            }

            series.Add(newSeriesLink);

            return(newSeriesLink);
        }
예제 #26
0
 private void getSeriesLinkBSEPG(EPGEntry epgEntry, int seriesLink)
 {
     epgEntry.Series = "SE-" + seriesLink;
     epgEntry.Episode = "EP-";
     epgEntry.EpisodeSystemType = "bsepg-epid";
     epgEntry.EpisodeSystemParts = 2;
 }
예제 #27
0
        private void setSeriesEpisode(EPGEntry epgEntry, int series, int episode)
        {
            if (RunParameters.Instance.Options.Contains("USEBSEPG"))
            {
                epgEntry.Series = "SE-" + series.ToString();
                epgEntry.Episode = "EP-" + episode.ToString();
                epgEntry.EpisodeSystemType = "bsepg-epid";
                epgEntry.EpisodeSystemParts = 2;
            }
            else
            {
                epgEntry.Series = series.ToString();
                epgEntry.Episode = episode.ToString();
                epgEntry.EpisodeSystemType = "xmltv_ns";
                epgEntry.EpisodeSystemParts = 3;
            }

            epgEntry.SeasonNumber = series;
            epgEntry.EpisodeNumber = episode;
        }
예제 #28
0
 private void getSkyAUSGBRSubTitle(EPGEntry epgEntry)
 {
     int colonIndex = epgEntry.ShortDescription.IndexOf(":");
     if (colonIndex != -1)
     {
         epgEntry.EventSubTitle = epgEntry.ShortDescription.Substring(0, colonIndex);
         epgEntry.ShortDescription = epgEntry.ShortDescription.Substring(colonIndex + 1);
     }
 }
예제 #29
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);
            }
        }
예제 #30
0
        private void getSkyGBREpisodeFormat2(EPGEntry epgEntry, int index1)
        {
            if (index1 < 3)
                return;

            int endOffset = 5;

            if (index1 + endOffset >= epgEntry.ShortDescription.Length)
                return;
            if (epgEntry.ShortDescription[index1 + endOffset] < '0' || epgEntry.ShortDescription[index1 + endOffset] > '9')
                return;
            if (epgEntry.ShortDescription[index1 - 1] < '0' || epgEntry.ShortDescription[index1 - 1] > '9')
                return;

            int index2 = index1 - 1;

            while (epgEntry.ShortDescription[index2] != 'S')
                index2--;

            if (epgEntry.ShortDescription[index2 - 1] != '(')
                return;

            int index3 = index1 + endOffset;

            while (epgEntry.ShortDescription[index3] >= '0' && epgEntry.ShortDescription[index3] <= '9')
                index3++;

            if (epgEntry.ShortDescription[index3] != ')')
                return;

            int series = 0;
            int index4 = index2 + 1;
            while (epgEntry.ShortDescription[index4] != ',')
            {
                series = (series * 10) + (epgEntry.ShortDescription[index4] - '0');
                index4++;
            }

            int episode = 0;
            int index5 = index1 + endOffset;
            while (index5 < index3)
            {
                episode = (episode * 10) + (epgEntry.ShortDescription[index5] - '0');
                index5++;
            }

            setSeriesEpisode(epgEntry, series, episode);

            if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA"))
                epgEntry.ShortDescription = epgEntry.ShortDescription.Remove(index2 - 1, index5 - index2 + 2).Trim();
        }
예제 #31
0
        private void extractDate(EPGEntry epgEntry, char startChar, char endChar)
        {
            int index1 = 0;

            while (index1 < epgEntry.ShortDescription.Length)
            {
                index1 = epgEntry.ShortDescription.IndexOf(startChar, index1);
                if (index1 == -1)
                    return;

                index1++;

                bool isDate = true;
                int index2 = 0;

                for (; index2 < 4; index2++)
                {
                    if (index2 + index1 == epgEntry.ShortDescription.Length)
                        return;

                    if (epgEntry.ShortDescription[index2 + index1] < '0' || epgEntry.ShortDescription[index2 + index1] > '9')
                        isDate = false;
                }

                if (index2 + index1 == epgEntry.ShortDescription.Length)
                    return;

                if (isDate)
                {
                    if (epgEntry.ShortDescription[index2 + index1] == endChar)
                    {
                        if (epgEntry.ShortDescription[index1] == '1' || epgEntry.ShortDescription[index1] == '2')
                        {
                            try
                            {
                                epgEntry.Date = epgEntry.ShortDescription.Substring(index1, 4);
                                if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA"))
                                    epgEntry.ShortDescription = epgEntry.ShortDescription.Remove(index1 - 1, 6).Trim();
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                return;
                            }
                        }
                    }
                }
            }
        }
예제 #32
0
        private void processCRIDBSEPG(EPGEntry epgEntry, string seriesID, string seasonID, string episodeID)
        {
            epgEntry.EpisodeSystemType = "bsepg-epid";
            epgEntry.EpisodeSystemParts = 2;

            string series = "SE-";
            string episode = "EP-";

            if (seriesID != null && seasonID != null && episodeID != null)
            {
                epgEntry.Series = series + ((uint)seasonID.GetHashCode()).ToString();
                epgEntry.Episode = episode + ((uint)episodeID.GetHashCode()).ToString();
                return;
            }

            if (seriesID != null && seasonID != null)
            {
                epgEntry.Series = series + ((uint)seriesID.GetHashCode()).ToString();
                epgEntry.Episode = episode + ((uint)seasonID.GetHashCode()).ToString();
                return;
            }

            if (seriesID != null)
            {
                if (episodeID != null)
                {
                    epgEntry.Series = series + ((uint)seriesID.GetHashCode()).ToString();
                    epgEntry.Episode = episode + ((uint)episodeID.GetHashCode()).ToString();
                }
                else
                {
                    epgEntry.Series = series + ((uint)seriesID.GetHashCode()).ToString();
                    epgEntry.Episode = episode;
                }

                return;
            }

            if (seasonID != null)
            {
                if (episodeID != null)
                {
                    epgEntry.Series = series + ((uint)seasonID.GetHashCode()).ToString();
                    epgEntry.Episode = episode + ((uint)episodeID.GetHashCode()).ToString();
                }
                else
                {
                    epgEntry.Series = series + ((uint)seasonID.GetHashCode()).ToString();
                    epgEntry.Episode = episode;
                }

                return;
            }

            epgEntry.Series = series;
            epgEntry.Episode = episode + ((uint)episodeID.GetHashCode()).ToString();
        }
예제 #33
0
        private void getAspectRatio(OpenTVTitleData titleData, EPGEntry epgEntry)
        {
            if (titleData.Flags == null || titleData.Flags.Length < 2)
                return;

            if ((titleData.Flags[0] & 0x08) != 0 || epgEntry.ShortDescription.IndexOf("(WS)") != -1)
            {
                epgEntry.AspectRatio = "16:9";
                if (!RunParameters.Instance.Options.Contains("NOREMOVEDATA"))
                    epgEntry.ShortDescription = epgEntry.ShortDescription.Replace("(WS)", "").Trim();
            }
        }
예제 #34
0
        private void setSeriesEpisode(EPGEntry epgEntry, FreeSatEntry freeSatEntry)
        {
            if (freeSatEntry.SeriesID == null && freeSatEntry.SeasonID == null && freeSatEntry.EpisodeID == null)
                return;

            if (RunParameters.Instance.Options.Contains("USENUMERICCRID"))
            {
                processCRIDNumeric(epgEntry, freeSatEntry.SeriesID, freeSatEntry.SeasonID, freeSatEntry.EpisodeID);
                return;
            }

            if (RunParameters.Instance.Options.Contains("USEBSEPG"))
            {
                processCRIDBSEPG(epgEntry, freeSatEntry.SeriesID, freeSatEntry.SeasonID, freeSatEntry.EpisodeID);
                return;
            }
        }
예제 #35
0
        private void getAudioQuality(OpenTVTitleData titleData, EPGEntry epgEntry)
        {
            if (titleData.Flags == null || titleData.Flags.Length < 2)
                return;

            switch (titleData.Flags[0] >> 6)
            {
                case 1:
                    epgEntry.AudioQuality = "stereo";
                    break;
                case 2:
                    epgEntry.AudioQuality = "surround";
                    break;
                case 3:
                    epgEntry.AudioQuality = "dolby digital";
                    break;
                default:
                    break;;
            }
        }
예제 #36
0
        private void processProgramTitle(string epgText, Logger titleLogger)
        {
            if (station == null)
                return;

            epgEntry = new EPGEntry();
            epgEntry.OriginalNetworkID = station.OriginalNetworkID;
            epgEntry.TransportStreamID = station.TransportStreamID;
            epgEntry.ServiceID = station.ServiceID;
            epgEntry.EPGSource = EPGSource.SiehfernInfo;

            string time = epgText.Substring(3, 5);
            int hours = Int32.Parse(time.Substring(0, 2));
            int minutes = Int32.Parse(time.Substring(3, 2));

            TimeSpan startTime = new TimeSpan(hours, minutes, 0);
            if (startDate + startTime < lastStartTime)
                startTime = startTime.Add(new TimeSpan(24, 0, 0));

            epgEntry.StartTime = Utils.RoundTime(startDate + startTime);

            int separatorIndex = epgText.IndexOf('|');
            if (separatorIndex == -1)
                epgEntry.EventName = epgText.Substring(9);
            else
                epgEntry.EventName = epgText.Substring(9, separatorIndex - 9);

            station.EPGCollection.Add(epgEntry);
            lastStartTime = epgEntry.StartTime;

            if (station.EPGCollection.Count > 1)
            {
                int count = station.EPGCollection.Count;
                if (station.EPGCollection[count - 2].Duration.TotalSeconds == 0)
                    station.EPGCollection[count - 2].Duration = Utils.RoundTime(station.EPGCollection[count - 1].StartTime - station.EPGCollection[count - 2].StartTime);
            }

            if (titleLogger != null)
            {
                titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                    epgEntry.StartTime.ToShortDateString() + " " +
                    epgEntry.StartTime.ToString("HH:mm") + " - " +
                    epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                    epgEntry.EventName + " " +
                    epgText);
            }
        }
예제 #37
0
        private void getDate(EPGEntry epgEntry)
        {
            extractDate(epgEntry, '(', ')');
            if (epgEntry.Date != null)
                return;

            extractDate(epgEntry, '[', ']');
        }
예제 #38
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;
            }
        }
예제 #39
0
 private void getDirector(EPGEntry epgEntry)
 {
     switch (RunParameters.Instance.CountryCode)
     {
         case "NZL":
             getSkyNZLDirector(epgEntry);
             break;
         default:
             break;
     }
 }
예제 #40
0
        private void getSeriesEpisode(EPGEntry epgEntry, int series, int episode)
        {
            if (series < 1 && episode < 1)
                return;

            epgEntry.EpisodeSystemType = "xmltv_ns";

            if (series > 0)
                epgEntry.Series = series.ToString();

            if (episode > 0)
                epgEntry.Episode = episode.ToString();
        }
예제 #41
0
        private void getEventCategory(OpenTVTitleData titleData, EPGEntry epgEntry)
        {
            if (titleData.CategoryID == 0)
            {
                getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription);
                return;
            }

            if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
            {
                epgEntry.EventCategory = getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription);
                if (epgEntry.EventCategory != null)
                    return;
            }

            OpenTVProgramCategory category = OpenTVProgramCategory.FindCategory(titleData.CategoryID);
            if (category != null)
            {
                epgEntry.EventCategory = category.Description;
                if (category.SampleEvent == null)
                    category.SampleEvent = epgEntry.FullScheduleDescription;
                category.UsedCount++;
                return;
            }
            else
                OpenTVProgramCategory.AddUndefinedCategory(titleData.CategoryID, epgEntry.FullScheduleDescription);

            if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
                return;

            epgEntry.EventCategory = getCustomCategory(epgEntry.EventName, epgEntry.ShortDescription);
        }
예제 #42
0
        private void logTitle(string title, EPGEntry epgEntry, Logger logger)
        {
            string episodeInfo;

            if (RunParameters.Instance.DebugIDs.Contains("LOGEPISODEINFO"))
            {
                if (epgEntry.EpisodeSystemType != null)
                    episodeInfo = epgEntry.Series + ":" + epgEntry.Episode + ":" + epgEntry.PartNumber;
                else
                    episodeInfo = string.Empty;
            }
            else
                episodeInfo = string.Empty;

            logger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                epgEntry.StartTime.ToShortDateString() + " " +
                epgEntry.StartTime.ToString("HH:mm") + " - " +
                epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                title + " " +
                episodeInfo);
        }
예제 #43
0
 private void getEventName(EPGEntry epgEntry, OpenTVTitleData titleData)
 {
     switch (RunParameters.Instance.CountryCode)
     {
         case "NZL":
             getSkyNZEventName(epgEntry, titleData);
             break;
         default:
             epgEntry.EventName = titleData.EventName;
             break;
     }
 }