Exemplo n.º 1
0
        public static ReserveData TryLoadTVPID(string filePath, IDictionary <ulong, ChSet5Item> chList)
        {
            Dictionary <string, string> paramList = TryLoadParamList(filePath);

            if (paramList != null &&
                paramList.ContainsKey("station") &&
                paramList.ContainsKey("version") &&
                paramList["version"] == "2")
            {
                // 放送種別とサービスID
                string station = paramList["station"];
                foreach (ChSet5Item info in chList.Values)
                {
                    ushort sid = 0;
                    if (ChSet5.IsDttv(info.ONID) &&
                        (station.StartsWith("DFS", StringComparison.Ordinal) || station.StartsWith("DOS", StringComparison.Ordinal)))
                    {
                        ushort.TryParse(station.Substring(3), NumberStyles.HexNumber, null, out sid);
                    }
                    else if (ChSet5.IsBS(info.ONID) && station.StartsWith("BSDT", StringComparison.Ordinal) ||
                             ChSet5.IsCS(info.ONID) && station.StartsWith("CSDT", StringComparison.Ordinal) ||
                             ChSet5.IsSP(info.ONID) && station.StartsWith("SPTV", StringComparison.Ordinal))
                    {
                        ushort.TryParse(station.Substring(4), out sid);
                    }
                    if (sid != 0 && sid == info.SID)
                    {
                        var addInfo = new ReserveData();
                        addInfo.OriginalNetworkID = info.ONID;
                        addInfo.TransportStreamID = info.TSID;
                        addInfo.ServiceID         = info.SID;
                        addInfo.StationName       = info.ServiceName;
                        // 開始時間と長さ
                        if (GetTimeValues(paramList, addInfo))
                        {
                            // イベントID(オプション)。なければプログラム予約
                            addInfo.EventID = 0xFFFF;
                            ushort eventID;
                            if (paramList.ContainsKey("program-id") && ushort.TryParse(paramList["program-id"], out eventID))
                            {
                                addInfo.EventID = eventID;
                            }
                            // 番組名(オプション)
                            if (paramList.ContainsKey("program-title"))
                            {
                                addInfo.Title = paramList["program-title"];
                            }
                            return(addInfo);
                        }
                        break;
                    }
                }
            }
            return(null);
        }