コード例 #1
0
        public GameSummaryCollection GetSummaryCollection(DateTime date)
        {
            var url = BuildUrl(date);
            GameSummaryCollection gameSummaryCollection = null;

            var xmlLoader = new XmlLoader();

            gameSummaryCollection = xmlLoader.GetXml <GameSummaryCollection>(url);

            return(gameSummaryCollection);
        }
コード例 #2
0
        private void CheckGames(object _ = null)
        {
            Logger.Log("CheckGames");

            this.checkGamesTimer?.Dispose();

            GameSummaryCollection summaryCollectionToday     = null;
            GameSummaryCollection summaryCollectionYesterday = null;

            try
            {
                summaryCollectionToday = this.gsc.GetSummaryCollection(this._date);
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                summaryCollectionYesterday = this.gsc.GetSummaryCollection(this._date.AddDays(-1));
            }
            catch (Exception)
            {
                // ignored
            }

            var todayGameSummaries     = summaryCollectionToday?.GameSummaries?.ToList() ?? new List <GameSummary>();
            var yesterdayGameSummaries = summaryCollectionYesterday?.GameSummaries?.ToList() ?? new List <GameSummary>();

            var todayHasGames     = todayGameSummaries.Any();
            var yesterdayHasGames = yesterdayGameSummaries.Any();

            if (!todayHasGames && !yesterdayHasGames)
            {
                Logger.Log("Games not found");
                return;
            }

            allGameSummaries = new List <GameSummary>();
            allGameSummaries.AddRange(todayGameSummaries);
            allGameSummaries.AddRange(yesterdayGameSummaries);

            if (this.activeGameTimes == null)
            {
                this.activeGameTimes = allGameSummaries
                                       .OrderBy(a => a.DateObjUtc)
                                       .Select(game => game.DateObjUtc.AddMinutes(-15));
            }

            var firstGameTime = this.activeGameTimes.First();
            //var now = firstGameTime.AddMinutes(5);
            var now = DateTime.UtcNow;
            var timeUntilFirstGame = firstGameTime - now;

            // Wait until 15 minutes before the first game of the day to check
            if (timeUntilFirstGame.TotalMinutes > 0)
            {
                this.StartCheckDelay(timeUntilFirstGame);

                return;
            }

            this.GetGameUpdates();
        }
コード例 #3
0
        public void Process()
        {
            GameSummaryCollection summary = null;

            try
            {
                summary = this.Gsc.GetSummaryCollection(this.Date);
            }
            catch (Exception e)
            {
            }

            if (summary?.GameSummaries == null || summary.GameSummaries.Length == 0)
            {
                Logger.Log("Skipping " + this.Date);
                return;
            }

            var tempList = new List <HighlightSearchResult>();

            foreach (var gameSummary in summary.GameSummaries)
            {
                var gdc = new GameDetailCreator(gameSummary.GameDataDirectory);
                HighlightsCollection highlights = null;

                try
                {
                    highlights = gdc.GetHighlights();
                }
                catch (Exception e)
                {
                }

                if (highlights?.Highlights == null || highlights.Highlights.Length == 0)
                {
                    continue;
                }

                foreach (var highlight in highlights.Highlights)
                {
                    highlight.url = highlight.url != null && highlight.url.Length > 0
                                                ? highlight.url.Where(a => a.Contains(".mp4")).ToArray()
                                                : new string[0];

                    if (highlight.url.Length == 0)
                    {
                        continue;
                    }

                    var newLocalHighlight = new HighlightSearchResult
                    {
                        GameId     = gameSummary.GamePk,
                        Highlight  = highlight,
                        Thumbnails = HighlightThumbnails.Make(highlight)
                    };

                    highlight.thumbnails = new string[0];

                    tempList.Add(newLocalHighlight);
                }
            }

            this.TempList = tempList;

            if (this.TempList.Any())
            {
                this.JsonSaveAll();
            }
        }