예제 #1
0
        /// <summary>
        /// Add an undefined category to the collection of undefined categories.
        /// </summary>
        /// <param name="number">The category ID.</param>
        /// <param name="description">The category description.</param>
        public static void AddUndefinedCategory(int number, string description)
        {
            if (undefinedCategories == null)
            {
                undefinedCategories = new Collection <OpenTVProgramCategory>();
            }

            foreach (OpenTVProgramCategory category in undefinedCategories)
            {
                if (category.number == number)
                {
                    return;
                }

                if (category.number > number)
                {
                    OpenTVProgramCategory insertCategory = new OpenTVProgramCategory(number, description);
                    insertCategory.usedCount = 1;
                    undefinedCategories.Insert(undefinedCategories.IndexOf(category), insertCategory);
                    return;
                }
            }

            OpenTVProgramCategory addCategory = new OpenTVProgramCategory(number, description);

            addCategory.usedCount = 1;
            undefinedCategories.Add(addCategory);
        }
예제 #2
0
        /// <summary>
        /// Acquire and process OpenTV data.
        /// </summary>
        /// <param name="dataProvider">A sampe data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            OpenTVProgramCategory.LoadFromCode(RunParameters.Instance.CountryCode.Trim());
            CustomProgramCategory.Load();
            ParentalRating.Load();

            bool referenceTablesLoaded = SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary " + RunParameters.Instance.CountryCode.Trim() + ".cfg"));

            if (!referenceTablesLoaded)
            {
                return(CollectorReply.ReferenceDataError);
            }

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            GetBouquetSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getTitleSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getSummarySections(dataProvider, worker);

            return(CollectorReply.OK);
        }
예제 #3
0
        /// <summary>
        /// Compare this instance with another for sorting purposes.
        /// </summary>
        /// <param name="category">The other instance.</param>
        /// <param name="keyName">The name of the key to compare on.</param>
        /// <returns>Zero if the instances are equal, Greater than 0 if this instance is greater; less than zero otherwise.</returns>
        public int CompareForSorting(OpenTVProgramCategory category, string keyName)
        {
            switch (keyName)
            {
            case "CategoryID":
                if (number == category.CategoryID)
                {
                    return(OpenTVDescription.CompareTo(category.OpenTVDescription));
                }
                else
                {
                    return(number.CompareTo(category.CategoryID));
                }

            case "Description":
                if (OpenTVDescription == category.OpenTVDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(OpenTVDescription.CompareTo(category.OpenTVDescription));
                }

            case "WMCDescription":
                string thisWMCDescription;
                string otherWMCDescription;

                if (WMCDescription != null)
                {
                    thisWMCDescription = WMCDescription;
                }
                else
                {
                    thisWMCDescription = string.Empty;
                }

                if (category.WMCDescription != null)
                {
                    otherWMCDescription = category.WMCDescription;
                }
                else
                {
                    otherWMCDescription = string.Empty;
                }

                if (thisWMCDescription == otherWMCDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisWMCDescription.CompareTo(otherWMCDescription));
                }

            case "DVBLogicDescription":
                string thisLogicDescription;
                string otherLogicDescription;

                if (DVBLogicDescription != null)
                {
                    thisLogicDescription = DVBLogicDescription;
                }
                else
                {
                    thisLogicDescription = string.Empty;
                }

                if (category.DVBLogicDescription != null)
                {
                    otherLogicDescription = category.DVBLogicDescription;
                }
                else
                {
                    otherLogicDescription = string.Empty;
                }

                if (thisLogicDescription == otherLogicDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisLogicDescription.CompareTo(otherLogicDescription));
                }

            case "DVBViewerDescription":
                string thisViewerDescription;
                string otherViewerDescription;

                if (DVBViewerDescription != null)
                {
                    thisViewerDescription = DVBViewerDescription;
                }
                else
                {
                    thisViewerDescription = string.Empty;
                }

                if (category.DVBViewerDescription != null)
                {
                    otherViewerDescription = category.DVBViewerDescription;
                }
                else
                {
                    otherViewerDescription = string.Empty;
                }

                if (thisViewerDescription == otherViewerDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisViewerDescription.CompareTo(otherViewerDescription));
                }

            default:
                return(0);
            }
        }
예제 #4
0
        /// <summary>
        /// Compare this instance with another for sorting purposes.
        /// </summary>
        /// <param name="category">The other instance.</param>
        /// <param name="keyName">The name of the key to compare on.</param>
        /// <returns>Zero if the instances are equal, Greater than 0 if this instance is greater; less than zero otherwise.</returns>
        public int CompareForSorting(OpenTVProgramCategory category, string keyName)
        {
            switch (keyName)
            {
                case "CategoryID":
                    if (number == category.CategoryID)
                        return (OpenTVDescription.CompareTo(category.OpenTVDescription));
                    else
                        return (number.CompareTo(category.CategoryID));
                case "Description":
                    if (OpenTVDescription == category.OpenTVDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (OpenTVDescription.CompareTo(category.OpenTVDescription));
                case "WMCDescription":
                    string thisWMCDescription;
                    string otherWMCDescription;

                    if (WMCDescription != null)
                        thisWMCDescription = WMCDescription;
                    else
                        thisWMCDescription = string.Empty;

                    if (category.WMCDescription != null)
                        otherWMCDescription = category.WMCDescription;
                    else
                        otherWMCDescription = string.Empty;

                    if (thisWMCDescription == otherWMCDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisWMCDescription.CompareTo(otherWMCDescription));
                case "DVBLogicDescription":
                    string thisLogicDescription;
                    string otherLogicDescription;

                    if (DVBLogicDescription != null)
                        thisLogicDescription = DVBLogicDescription;
                    else
                        thisLogicDescription = string.Empty;

                    if (category.DVBLogicDescription != null)
                        otherLogicDescription = category.DVBLogicDescription;
                    else
                        otherLogicDescription = string.Empty;

                    if (thisLogicDescription == otherLogicDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisLogicDescription.CompareTo(otherLogicDescription));
                case "DVBViewerDescription":
                    string thisViewerDescription;
                    string otherViewerDescription;

                    if (DVBViewerDescription != null)
                        thisViewerDescription = DVBViewerDescription;
                    else
                        thisViewerDescription = string.Empty;

                    if (category.DVBViewerDescription != null)
                        otherViewerDescription = category.DVBViewerDescription;
                    else
                        otherViewerDescription = string.Empty;

                    if (thisViewerDescription == otherViewerDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisViewerDescription.CompareTo(otherViewerDescription));
                default:
                    return (0);
            }
        }
예제 #5
0
        /// <summary>
        /// Add an undefined category to the collection of undefined categories.
        /// </summary>
        /// <param name="number">The category ID.</param>
        /// <param name="description">The category description.</param>
        public static void AddUndefinedCategory(int number, string description)
        {
            if (undefinedCategories == null)
                undefinedCategories = new Collection<OpenTVProgramCategory>();

            foreach (OpenTVProgramCategory category in undefinedCategories)
            {
                if (category.number == number)
                    return;

                if (category.number > number)
                {
                    OpenTVProgramCategory insertCategory = new OpenTVProgramCategory(number, description);
                    insertCategory.usedCount = 1;
                    undefinedCategories.Insert(undefinedCategories.IndexOf(category), insertCategory);
                    return;
                }
            }

            OpenTVProgramCategory addCategory = new OpenTVProgramCategory(number, description);
            addCategory.usedCount = 1;
            undefinedCategories.Add(addCategory);
        }
예제 #6
0
        /// <summary>
        /// Carry out the processing after all data has been collected for a frequency.
        /// </summary>
        public override void FinishFrequency()
        {
            if (OpenTVChannel.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger               = null;
            Logger descriptionLogger         = null;
            Logger extendedDescriptionLogger = null;
            Logger undefinedRecordLogger     = null;

            if (RunParameters.Instance.DebugIDs.Contains("LOGTITLES"))
            {
                titleLogger = new Logger("EPG Titles.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTIONS"))
            {
                descriptionLogger = new Logger("EPG Descriptions.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGEXTENDEDDESCRIPTIONS"))
            {
                extendedDescriptionLogger = new Logger("EPG Extended Descriptions.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGUNDEFINEDRECORDS"))
            {
                undefinedRecordLogger = new Logger("EPG Undefined Records.log");
            }

            foreach (OpenTVChannel channel in OpenTVChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station != null)
                {
                    if (station.EPGCollection.Count == 0)
                    {
                        channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, extendedDescriptionLogger, undefinedRecordLogger);
                        channel.CreateChannelMapping(station);
                    }
                }
            }

            if (RunParameters.Instance.DebugIDs.Contains("LOGCHANNELS"))
            {
                Logger.Instance.WriteSeparator("Bouquet Usage");

                bool firstBouquet = true;

                foreach (Bouquet bouquet in Bouquet.GetBouquetsInNameOrder())
                {
                    if (!firstBouquet)
                    {
                        Logger.Instance.Write("");
                    }

                    firstBouquet = false;

                    foreach (Region region in bouquet.Regions)
                    {
                        Logger.Instance.Write("Bouquet: " + bouquet.BouquetID + " - " + bouquet.Name + " Region: " + region.Code + " (channels = " + region.Channels.Count + ")");

                        foreach (Channel channel in region.GetChannelsInNameOrder())
                        {
                            Logger.Instance.Write("    Channel: " + channel.ToString());
                        }
                    }
                }
            }

            int count = 0;

            foreach (TuningFrequency frequency in TuningFrequency.FrequencyCollection)
            {
                if (frequency.CollectionType == CollectionType.OpenTV)
                {
                    count++;
                }
            }

            if (count > 1)
            {
                bool frequencyFirst = true;

                foreach (TuningFrequency frequency in TuningFrequency.FrequencyCollection)
                {
                    if (frequency.CollectionType == CollectionType.OpenTV)
                    {
                        if (frequencyFirst)
                        {
                            Logger.Instance.WriteSeparator("Frequency Usage");
                            frequencyFirst = false;
                        }
                        Logger.Instance.Write("Frequency " + frequency.Frequency + " usage count " + frequency.UsageCount);
                    }
                }
            }

            OpenTVProgramCategory.LogCategoryUsage();

            if (RunParameters.Instance.DebugIDs.Contains("LOGCHANNELDATA"))
            {
                if (OpenTVChannel.Channels.Count != 0)
                {
                    Logger.Instance.WriteSeparator("Channel Data - ID Sequence");

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }

                    Collection <OpenTVChannel> sortedChannels = new Collection <OpenTVChannel>();

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        addByUserChannel(sortedChannels, channel);
                    }

                    Logger.Instance.WriteSeparator("Channel Data - User Channel Sequence");

                    foreach (OpenTVChannel channel in sortedChannels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }

                    sortedChannels = new Collection <OpenTVChannel>();

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        addByFlags(sortedChannels, channel);
                    }

                    Logger.Instance.WriteSeparator("Channel Data - Flags Sequence");

                    foreach (OpenTVChannel channel in sortedChannels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }
                }
            }
        }