Esempio n. 1
0
        private static bool getStations(TuningFrequency frequency)
        {
            bool tuned = tuneFrequency(frequency);

            if (!tuned)
            {
                return(false);
            }

            FrequencyScanner       frequencyScanner = new FrequencyScanner(graph);
            Collection <TVStation> stations         = frequencyScanner.FindTVStations(frequency);

            if (stations != null)
            {
                Logger.Instance.Write("Found " + stations.Count + " stations on frequency " + frequency);
                int addedCount = 0;

                foreach (TVStation tvStation in stations)
                {
                    TVStation excludedStation = TVStation.FindExcludedStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (excludedStation == null)
                    {
                        if (tvStation.NextFollowingAvailable && tvStation.ScheduleAvailable)
                        {
                            bool added = TVStation.AddStation(tvStation);
                            if (added)
                            {
                                //allStations.Add(tvStation);
                                addedCount++;
                                Logger.Instance.Write("Included station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ") No EPG data");
                        }
                    }
                    else
                    {
                        Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                    }
                }

                Logger.Instance.Write("Added " + addedCount + " stations for frequency " + frequency);
            }
            frequencyScanner = null;
            return(true);
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway2);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            foreach (MediaHighwaySummary summary in MediaHighwaySummary.Summaries)
            {
                if (summary.Replays != null)
                {
                    MediaHighwayChannelTitle title = MediaHighwayChannel.FindChannelTitle(summary.EventID);
                    if (title != null)
                    {
                        foreach (MediaHighway1Replay replay in summary.Replays)
                        {
                            MediaHighwayTitle replayTitle = new MediaHighwayTitle();
                            replayTitle.EventID          = title.Title.EventID;
                            replayTitle.EventName        = title.Title.EventName;
                            replayTitle.CategoryID       = title.Title.CategoryID;
                            replayTitle.StartTime        = replay.ReplayTime;
                            replayTitle.Duration         = title.Title.Duration;
                            replayTitle.SummaryAvailable = true;
                            replayTitle.PreviousPlayDate = title.Title.StartTime;
                            ((MediaHighwayChannel)Channel.FindChannel(replay.Channel)).AddTitleData(replayTitle);

                            if (RunParameters.Instance.DebugIDs.Contains("REPLAYS"))
                            {
                                Logger.Instance.Write("Replay: ch" + replay.Channel + " " +
                                                      title.Title.EventName + " " +
                                                      title.Title.StartTime + " " +
                                                      title.Title.Duration + " " +
                                                      replay.ReplayTime);
                            }
                        }
                    }
                }
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway1);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (RunParameters.Instance.DebugIDs.Contains("LOGPSIPEXTENDEDTEXT"))
            {
                ExtendedTextTable.LogEntries();
            }

            AtscPsipProgramCategory.LogCategoryUsage();

            if (VirtualChannelTable.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (VirtualChannel channel in VirtualChannelTable.Channels)
            {
                TVStation station = TVStation.FindStation(channel.CollectionFrequency, channel.MajorChannelNumber, channel.MinorChannelNumber);
                if (station == null)
                {
                    station = new TVStation(channel.ShortName);
                    station.OriginalNetworkID = channel.CollectionFrequency;
                    station.TransportStreamID = channel.MajorChannelNumber;
                    station.ServiceID         = channel.MinorChannelNumber;
                    station.ChannelID         = channel.MajorChannelNumber + ":" + channel.MinorChannelNumber + ":" + channel.ShortName;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ShortName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = (channel.MajorChannelNumber * 100) + channel.MinorChannelNumber;
                }

                station.MinorChannelNumber = channel.MinorChannelNumber;

                if (station.EPGCollection.Count == 0)
                {
                    foreach (EPGEntry epgEntry in channel.EPGCollection)
                    {
                        station.EPGCollection.Add(epgEntry);

                        if (titleLogger != null)
                        {
                            titleLogger.Write(epgEntry.ServiceID + " " +
                                              epgEntry.StartTime.ToShortDateString() + " " +
                                              epgEntry.StartTime.ToString("HH:mm") + " - " +
                                              epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                              epgEntry.EventName);
                        }

                        if (descriptionLogger != null && epgEntry.ShortDescription != null)
                        {
                            descriptionLogger.Write(epgEntry.ServiceID + " " +
                                                    " Evt ID " + epgEntry.EventID +
                                                    epgEntry.StartTime.ToShortDateString() + " " +
                                                    epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                    epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                    epgEntry.ShortDescription);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Get the stations using specified pid's.
        /// </summary>
        /// <param name="dataProvider">The sample data provider.</param>
        /// <param name="worker">The BackgroundWorker instance running the collection.</param>
        /// <param name="pids">An array of pid's to search.</param>
        protected void GetStationData(ISampleDataProvider dataProvider, BackgroundWorker worker, int[] pids)
        {
            Collection <TVStation> stations;

            if (!RunParameters.Instance.Options.Contains("USESTOREDSTATIONINFO"))
            {
                FrequencyScanner frequencyScanner = new FrequencyScanner(dataProvider, pids, true, worker);
                frequencyScanner.UseActualFrequency = false;
                stations = frequencyScanner.FindTVStations();
                if (worker.CancellationPending)
                {
                    return;
                }
            }
            else
            {
                if (!stationCacheLoaded)
                {
                    stations = TVStation.Load(Path.Combine(RunParameters.DataDirectory, "Station Cache.xml"));
                    if (stations == null)
                    {
                        return;
                    }

                    setMHEG5Pid(dataProvider, stations);
                    stationCacheLoaded = true;
                }
                else
                {
                    setMHEG5Pid(dataProvider, TVStation.StationCollection);
                    return;
                }
            }

            foreach (TVStation tvStation in stations)
            {
                bool include = checkChannelFilters(tvStation);

                if (include)
                {
                    TVStation existingStation = TVStation.FindStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (existingStation == null)
                    {
                        tvStation.CollectionType = dataProvider.Frequency.CollectionType;
                        bool added = TVStation.AddStation(tvStation);
                        if (added)
                        {
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                        }
                    }
                    else
                    {
                        if (!existingStation.Excluded)
                        {
                            existingStation.Update(tvStation);
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                        }
                        else
                        {
                            Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));
                        }
                    }
                }
                else
                {
                    Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));
                }
            }

            Logger.Instance.Write("Station count now: " + TVStation.StationCollection.Count);
        }