Beispiel #1
0
        public static List<Games> GetGames(NPGGFFLDataContext context, int year, int seasonType, int weekNum)
        {
            var games = new List<Games>();
            Regex gameRX = new Regex("gameId=[0-9]+");
            var url = string.Format("{0}/{1}", GAME_URL, string.Format("_/year/{0}/seasontype/{1}/week/{2}", year.ToString(), seasonType.ToString(), weekNum.ToString()));
            var html = HelperMethods.LoadHtmlFromUrl(url);
            var gameIds = gameRX.Matches(html);

            foreach (Match gId in gameIds)
            {
                var gameId = System.Convert.ToInt32(gId.Value.Replace("gameId=", string.Empty));

                if (!games.Select(g => g.GameId).Contains(gameId))
                {
                    try
                    {
                        var teamsForGame = GetTeamsByGame(gameId);

                        var homeTeam = context.Teams.Where(t => t.Abbreviation.ToUpper().Equals(teamsForGame["home"])).FirstOrDefault();
                        var awayTeam = context.Teams.Where(t => t.Abbreviation.ToUpper().Equals(teamsForGame["away"])).FirstOrDefault();

                        Games game = new Games();
                        game.GameId = gameId;
                        game.HomeTeamId = homeTeam.TeamId;
                        game.AwayTeamId = awayTeam.TeamId;
                        game.GameDtm = GetGameDate(gameId);
                        games.Add(game);
                    }
                    catch { }
                }
            }

            return games.Distinct().ToList();
        }
Beispiel #2
0
        public static void GetDefensiveTDs(NPGGFFLDataContext context, Games game)
        {
            var foxSeasonType = (game.SeasonWeeks.SeasonTypeId == 1 ? 3 : (game.SeasonWeeks.SeasonTypeId == 2 ? 1 : 2));    //preseason = 3, reg season = 1, postseason = 2
            var foxScheduleUrl = string.Format("{0}?season={1}&seasonType={2}&week={3}", new string[] { SCHEDULE_URL, game.SeasonWeeks.SeasonYear.ToString(), foxSeasonType.ToString(), game.SeasonWeeks.WeekNum.ToString() });
            var foxLeagueUrl = string.Format("{0}?season={1}", new string[] { LEAGUE_URL, game.SeasonWeeks.SeasonYear.ToString() });

            var leagueJson = JObject.Parse(HelperMethods.GetJsonFromUrl(foxLeagueUrl));
            var scheduleJson = JArray.Parse(HelperMethods.GetJsonFromUrl(foxScheduleUrl));

            var awayTeam = GetFoxTeam(leagueJson, game.AwayTeam.FoxAbbreviation.ToUpper());
            var homeTeam = GetFoxTeam(leagueJson, game.HomeTeam.FoxAbbreviation.ToUpper());
            var gameUrl = string.Format("{0}{1}&type=3", HOST, GetFoxBoxscoreUrl(scheduleJson, awayTeam, homeTeam));

            var html = HelperMethods.LoadHtmlFromUrl(gameUrl);
            var dom = new CQ(html, HtmlParsingMode.Document);

            var dTDs = dom["div[class*='wisfb_bsTeamStats']"].Find("tr[class*='wisfb_bstsTotal wisfb_bstsGroupTop']:contains('DEF TDs')");
            if (dTDs.Length > 0)
            {
                var awayDefensiveTDs = Convert.ToInt32(dTDs.Find("td[class*='wisfb_bstsStat']")[0].Cq().Html());
                var homeDefensiveTDs = Convert.ToInt32(dTDs.Find("td[class*='wisfb_bstsStat']")[1].Cq().Html());

                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.AwayTeamId).First().DefensiveTDs = awayDefensiveTDs;
                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.HomeTeamId).First().DefensiveTDs = homeDefensiveTDs;
                context.SubmitChanges();
            }
        }
 public static void MarkPlayerStatsFinal(Games game, NPGGFFLDataContext context)
 {
     if (game.IsFinal == 1)
     {
         context.ExecuteCommand("update playerstats set isfinal = 1 where gameid = {0} and isfinal = 0", (new string[] { game.GameId.ToString() }));
     }
 }
 public static void LockPlayersAndStartStats(Games game, NPGGFFLDataContext context)
 {
     if (!game.IsStarted)
     {
         var startDtm = DateTime.Now;
         var seasonWeek = context.SeasonWeeks.Where(sw => sw.StartDtm <= game.GameDtm && sw.EndDtm >= game.GameDtm).First();
         context.ExecuteCommand("update games set IsLocked = 1, IsStarted = 1 where SeasonWeekId = {0} and GameId = {1}", (new string[] { seasonWeek.SeasonWeekId.ToString(), game.GameId.ToString() }));
         context.ExecuteCommand("update OwnerTeams set IsLocked = 1 where islocked = 0 and seasonweekid = {0} and exists (select 1 from players p where p.playerid = playerid and exists (select 1 from games g where g.seasonweekid = {1} and g.GameId = {2} and (g.HomeTeamId = p.teamid or g.AwayTeamId = p.TeamId)))", (new string[] { seasonWeek.SeasonWeekId.ToString(), seasonWeek.SeasonWeekId.ToString(), game.GameId.ToString() }));
         context.ExecuteCommand("insert into playerstats (playerid, gameid) select p.playerid, g.gameid from players p, games g WHERE (g.hometeamid = p.teamid or g.awayteamid = p.teamid) and g.seasonweekid = {0} and g.GameId = {1} and not exists (select 1 from playerstats ps where ps.playerid = p.playerid and ps.gameid = g.gameid)", (new string[] { seasonWeek.SeasonWeekId.ToString(), game.GameId.ToString() }));
         Console.WriteLine("Lock Players & Start Stats took " + (DateTime.Now - startDtm).TotalSeconds);
     }
 }
Beispiel #5
0
 public static void UpdateStatsByGame(Games game, NPGGFFLDataContext context)
 {
     try
     {
         Console.WriteLine(string.Format("{0}: {1} vs. {2}", "Getting Stats for game", game.HomeTeam.Name, game.AwayTeam.Name));
         var scoreStripJson = JObject.Parse(HelperMethods.GetJsonFromUrl(string.Format(SS_URL, HelperMethods.CacheBuster())));
         var eid = scoreStripJson["gms"].Where(g => g["vnn"].Value<string>().ToUpper().Equals(game.AwayTeam.Name.ToUpper())).FirstOrDefault()["eid"].Value<string>();
         var gameCenterJson = JObject.Parse(HelperMethods.GetJsonFromUrl(string.Format(GAMECENTER_URL, eid, HelperMethods.CacheBuster())));
         if (gameCenterJson.Count != 0)
         {
             GeneralScraperMethods.LockPlayersAndStartStats(game, context);
             UpdateStats(game, context, eid, gameCenterJson);
             GeneralScraperMethods.MarkPlayerStatsFinal(game, context);
         }
     }
     catch { }
 }
Beispiel #6
0
 partial void DeleteGames(Games instance);
Beispiel #7
0
 partial void UpdateGames(Games instance);
Beispiel #8
0
 partial void InsertGames(Games instance);
Beispiel #9
0
		private void detach_Games1(Games entity)
		{
			this.SendPropertyChanging();
			entity.HomeTeam = null;
		}
Beispiel #10
0
		private void attach_Games1(Games entity)
		{
			this.SendPropertyChanging();
			entity.HomeTeam = this;
		}
Beispiel #11
0
		private void detach_Games(Games entity)
		{
			this.SendPropertyChanging();
			entity.SeasonWeeks = null;
		}
Beispiel #12
0
 public static void UpdateStatsByGame(Games game, NPGGFFLDataContext context)
 {
     Console.WriteLine(string.Format("{0}: {1} vs. {2}", "Getting Stats for game", game.HomeTeam.Name, game.AwayTeam.Name));
     GeneralScraperMethods.LockPlayersAndStartStats(game, context);
     UpdateStatsByBoxScore(game, context);
     UpdateStatsPlayByPlay(game, context);
     UpdateStatsByMatchup(game, context);
     GeneralScraperMethods.MarkPlayerStatsFinal(game, context);
 }
Beispiel #13
0
        private static void UpdateStats(Games game, NPGGFFLDataContext context, string eid, JObject gameCenterJson)
        {
            #region Update Game Stats
            var gameStatus = gameCenterJson[eid]["qtr"].Value<string>();
            if (gameStatus.Equals("Final"))
            {
                game.GameTimeRemaining = "Final";
                game.IsFinal = 1;
            }
            else
            {
                var gameTimeRemaining = gameCenterJson[eid]["clock"].Value<string>();
                game.GameTimeRemaining = gameTimeRemaining;
            }
            #region Update Team Stats
            var awayScore = gameCenterJson[eid]["away"]["score"]["T"].Value<int>(); ;
            context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.HomeTeamId).First().PointsAllowed = awayScore;
            game.AwayPointsScored = awayScore;

            var homeScore = gameCenterJson[eid]["home"]["score"]["T"].Value<int>();
            context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.AwayTeamId).First().PointsAllowed = homeScore;
            game.HomePointsScored = homeScore;
            context.SubmitChanges();

            #endregion

            #endregion

            #region Get Home Stats
            var hpassing = gameCenterJson[eid]["home"]["stats"]["passing"];
            var hrushing = gameCenterJson[eid]["home"]["stats"]["rushing"];
            var hreceiving = gameCenterJson[eid]["home"]["stats"]["receiving"];
            var hfumbles = gameCenterJson[eid]["home"]["stats"]["fumbles"];
            var hkicking = gameCenterJson[eid]["home"]["stats"]["kicking"];
            //var hpunting = gameCenterJson[eid]["home"]["stats"]["punting"];
            //var hkickret = gameCenterJson[eid]["home"]["stats"]["kickret"];
            //var hpuntret = gameCenterJson[eid]["home"]["stats"]["puntret"];
            //var hdefense = gameCenterJson[eid]["home"]["stats"]["defense"];
            //var hteam = gameCenterJson[eid]["home"]["stats"]["team"];
            ProcessPlayerStats(context, hpassing, "passing", game.GameId);
            ProcessPlayerStats(context, hrushing, "rushing", game.GameId);
            ProcessPlayerStats(context, hreceiving, "receiving", game.GameId);
            ProcessPlayerStats(context, hfumbles, "fumbles", game.GameId);
            ProcessPlayerStats(context, hkicking, "kicking", game.GameId);
            //ProcessPlayerStats(context, hpunting, "punting", game.GameId);
            //ProcessPlayerStats(context, hkickret, "kickret", game.GameId);
            //ProcessPlayerStats(context, hpuntret, "puntret", game.GameId);
            //ProcessPlayerStats(context, hdefense, "defense", game.GameId);
            //ProcessPlayerStats(context, hteam);
            #endregion

            #region Get Away Stats
            var apassing = gameCenterJson[eid]["away"]["stats"]["passing"];
            var arushing = gameCenterJson[eid]["away"]["stats"]["rushing"];
            var areceiving = gameCenterJson[eid]["away"]["stats"]["receiving"];
            var afumbles = gameCenterJson[eid]["away"]["stats"]["fumbles"];
            var akicking = gameCenterJson[eid]["away"]["stats"]["kicking"];
            //var apunting = gameCenterJson[eid]["away"]["stats"]["punting"];
            //var akickret = gameCenterJson[eid]["away"]["stats"]["kickret"];
            //var apuntret = gameCenterJson[eid]["away"]["stats"]["puntret"];
            //var adefense = gameCenterJson[eid]["away"]["stats"]["defense"];
            //var ateam = gameCenterJson[eid]["away"]["stats"]["team"];
            ProcessPlayerStats(context, apassing, "passing", game.GameId);
            ProcessPlayerStats(context, arushing, "rushing", game.GameId);
            ProcessPlayerStats(context, areceiving, "receiving", game.GameId);
            ProcessPlayerStats(context, afumbles, "fumbles", game.GameId);
            ProcessPlayerStats(context, akicking, "kicking", game.GameId);
            //ProcessPlayerStats(context, apunting, "punting", game.GameId);
            //ProcessPlayerStats(context, akickret, "kickret", game.GameId);
            //ProcessPlayerStats(context, apuntret, "puntret", game.GameId);
            //ProcessPlayerStats(context, adefense, "defense", game.GameId);
            //ProcessPlayerStats(context, ateam);
            #endregion
        }
Beispiel #14
0
        private static Players InsertPlayerById(NPGGFFLDataContext context, int playerId, Games game)
        {
            var playerExists = context.Players.Where(p => p.PlayerId == playerId).FirstOrDefault();
            if (playerExists == null)
            {
                var url = string.Format("{0}/{1}", PLAYER_URL, playerId.ToString());
                var html = HelperMethods.LoadHtmlFromUrl(url);
                CQ dom = new CQ(html, HtmlParsingMode.Document);
                var playerName = string.Empty;
                var position = string.Empty;
                var team = string.Empty;

                try
                {
                    playerName = dom["div[class*='mod-split-menu']"].First().Find("a[class*='btn-split-btn']").First().Html().Trim();
                    position = dom["div[class*='player-bio']"].Find("ul[class*='general-info']").Find("li").First().Html().Split(' ')[1].Trim();
                    team = dom["ul[class*='general-info']"].Find("a[href*='/team/']").Attr("href").Split('/')[7].Trim();
                }
                catch { }

                Players player = new Players();
                player.PlayerId = playerId;
                player.Name = playerName;

                var playerTeam = context.Teams.Where(t => t.Abbreviation.ToUpper().Equals(team.ToUpper())).FirstOrDefault();
                if (playerTeam != null)
                {
                    player.TeamId = playerTeam.TeamId;
                }
                else
                {
                    player.TeamId = 35; //no team
                }

                player.PositionId = InsertPositionByName(context, position).PositionId;
                context.Players.InsertOnSubmit(player);
                context.SubmitChanges();
                return context.Players.Where(p => p.PlayerId == playerId).FirstOrDefault();
            }
            else if (playerExists.TeamId != game.HomeTeamId && playerExists.TeamId != game.AwayTeamId)
            {
                var url = string.Format("{0}/{1}", PLAYER_URL, playerId.ToString());
                var html = HelperMethods.LoadHtmlFromUrl(url);
                CQ dom = new CQ(html, HtmlParsingMode.Document);
                var playerName = string.Empty;
                var position = string.Empty;
                var team = string.Empty;

                try
                {
                    playerName = dom["div[class*='mod-split-menu']"].First().Find("a[class*='btn-split-btn']").First().Html().Trim();
                    position = dom["div[class*='player-bio']"].Find("ul[class*='general-info']").Find("li").First().Html().Split(' ')[1].Trim();
                    team = dom["ul[class*='general-info']"].Find("a[href*='/team/']").Attr("href").Split('/')[7].Trim();
                }
                catch { }

                var playerTeam = context.Teams.Where(t => t.Abbreviation.ToUpper().Equals(team.ToUpper())).FirstOrDefault();
                if (playerTeam != null)
                {
                    playerExists.TeamId = playerTeam.TeamId;
                }
                else
                {
                    playerExists.TeamId = 35; //no team
                }

                context.SubmitChanges();
                return playerExists;
            }
            else
            {
                return playerExists;
            }
        }
Beispiel #15
0
        public static void UpdateStatsPlayByPlay(Games game, NPGGFFLDataContext context)
        {
            var startDtm = DateTime.Now;
            var gameId = game.GameId;
            var url = string.Format("{0}{1}", LIVE_URL, string.Format("?gameId={0}", gameId.ToString()));
            var html = HelperMethods.LoadHtmlFromUrl(url);
            CQ dom = new CQ(html, HtmlParsingMode.Document);

            if (dom["#gamepackage-play-by-play:contains('No Drives')"].Length == 0)
            {
                #region Update Two Point Conversions
                Dictionary<int, int> twoPointConversionPlayerList = new Dictionary<int, int>();
                var twoPointConversionRows = dom["div[class*='headline']:contains('TWO-POINT')"];
                foreach (var tpcr in twoPointConversionRows)
                {
                    var tpcrHTML = tpcr.Cq().Html();
                    if (tpcrHTML.Contains("ATTEMPT SUCCEEDS"))
                    {
                        var tpcStart = tpcrHTML.IndexOf("TWO-POINT CONVERSION ATTEMPT.") + 29;
                        var tpcEnd = tpcrHTML.IndexOf("ATTEMPT SUCCEEDS");
                        var twoPointText = tpcrHTML.Substring(tpcStart, tpcEnd - tpcStart);
                        var splitIntoWords = twoPointText.Split(' ');

                        foreach (var word in splitIntoWords.Where(w => w.Contains(".")))
                        {
                            var findPlayer = context.Players.Where(p => p.PlayerStats.Where(ps => ps.PlayerId == p.PlayerId && ps.GameId == gameId).Count() != 0 && p.Name.Substring(0, 1).ToUpper() == word.Split('.')[0].Trim().ToUpper() && p.Name.ToUpper().Contains(word.Split('.')[1].Trim().ToUpper()));
                            if (findPlayer.Count() > 1)
                            {
                                var bestMatch = new Players();
                                var shortestDistance = 100;
                                foreach (var fp in findPlayer)
                                {
                                    if (HelperMethods.LevenshteinDistance.Compute(fp.Name.ToUpper(), word.ToUpper()) < shortestDistance)
                                    {
                                        shortestDistance = HelperMethods.LevenshteinDistance.Compute(fp.Name.ToUpper(), word.ToUpper());
                                        bestMatch = fp;
                                    }
                                }

                                if (!twoPointConversionPlayerList.ContainsKey(bestMatch.PlayerId))
                                {
                                    twoPointConversionPlayerList.Add(bestMatch.PlayerId, 1);
                                }
                                else
                                {
                                    twoPointConversionPlayerList[bestMatch.PlayerId]++;
                                }
                            }
                            else if (findPlayer.Count() == 1)
                            {
                                if (!twoPointConversionPlayerList.ContainsKey(findPlayer.First().PlayerId))
                                {
                                    twoPointConversionPlayerList.Add(findPlayer.First().PlayerId, 1);
                                }
                                else
                                {
                                    twoPointConversionPlayerList[findPlayer.First().PlayerId]++;
                                }
                            }
                        }
                    }
                }

                foreach (var tpc in twoPointConversionPlayerList)
                {
                    var playerStats = context.PlayerStats.Where(ps => ps.PlayerId == tpc.Key && ps.GameId == gameId).FirstOrDefault();
                    if (playerStats != null)
                    {
                        playerStats.TwoPointConversions = tpc.Value;
                        context.SubmitChanges();
                    }
                }
                #endregion

                #region Update Safeties
                FindSafeties(context, gameId);
                #endregion

                #region Update Game Progress
                var gameStatus = dom["div[class*='game-status']"].Has("span:contains('Final')");
                if (gameStatus.Length > 0)
                {
                    game.IsFinal = 1;
                    context.SubmitChanges();
                }
                else
                {
                    var timeRemaining = dom["span[class*='game-time']"].Html();
                    game.GameTimeRemaining = timeRemaining;
                    context.SubmitChanges();
                }
                #endregion
            }

            Console.WriteLine("Update Stats Play By Play took " + (DateTime.Now - startDtm).TotalSeconds);
        }
Beispiel #16
0
        public static void UpdateStatsByMatchup(Games game, NPGGFFLDataContext context)
        {
            var startDtm = DateTime.Now;
            var gameId = game.GameId;
            var url = string.Format("{0}{1}", MATCHUP_URL, string.Format("?gameId={0}", gameId.ToString()));
            var html = HelperMethods.LoadHtmlFromUrl(url);
            CQ dom = new CQ(html, HtmlParsingMode.Document);

            if (dom["#gamepackage-matchup:contains('No Team Stats Available')"].Length == 0)
            {
                //var defensiveTDsStatLine = dom["tr[data-stat-attr*='defensiveTouchdowns']"];

                //if (defensiveTDsStatLine.Length > 0)
                //{
                //    var awayDefensiveTDs = Convert.ToInt32(defensiveTDsStatLine.Find("td")[1].Cq().Html());
                //    var homeDefensiveTDs = Convert.ToInt32(defensiveTDsStatLine.Find("td")[2].Cq().Html());

                //    context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.AwayTeamId).First().DefensiveTDs = awayDefensiveTDs;
                //    context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.HomeTeamId).First().DefensiveTDs = homeDefensiveTDs;
                //    context.SubmitChanges();
                //}

                FoxSportsScraper.GetDefensiveTDs(context, game);
            }
            Console.WriteLine("Update Stats By Matchup took " + (DateTime.Now - startDtm).TotalSeconds);
        }
Beispiel #17
0
		private void attach_Games(Games entity)
		{
			this.SendPropertyChanging();
			entity.SeasonWeeks = this;
		}
Beispiel #18
0
        public static void UpdateStatsByBoxScore(Games game, NPGGFFLDataContext context)
        {
            var startDtm = DateTime.Now;
            var gameId = game.GameId;
            var url = string.Format("{0}{1}", BOXSCORE_URL, string.Format("?gameId={0}", gameId.ToString()));
            var html = HelperMethods.LoadHtmlFromUrl(url);
            CQ dom = new CQ(html, HtmlParsingMode.Document);

            if (dom["#main-container:contains('No Box Score Available')"].Length == 0)
            {
                #region Update Game Stats
                var gameStatus = dom["div[class*='game-status']"];
                if (gameStatus.Find(":contains('Final')").Length > 0)
                {
                    game.GameTimeRemaining = "Final";
                }
                else
                {
                    var gameTimeRemaining = dom["span[class*='game-time']"].Html().Trim();
                    game.GameTimeRemaining = gameTimeRemaining;
                }

                #region Update Team Stats
                //var awayTeamStats = GeneralScraperMethods.InsertTeamStatsByTeamIdGameId(context, game.AwayTeamId, game.GameId);
                var awayScore = dom["div[class*='competitors']"].Find("div[class*='team away']").Find("div[class*='score-container']").Find("div").Html().Trim();
                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.HomeTeamId).First().PointsAllowed = Convert.ToInt32(awayScore);
                game.AwayPointsScored = Convert.ToInt32(awayScore);

                //var homeTeamStats = GeneralScraperMethods.InsertTeamStatsByTeamIdGameId(context, game.HomeTeamId, game.GameId);
                var homeScore = dom["div[class*='competitors']"].Find("div[class*='team home']").Find("div[class*='score-container']").Find("div").Html().Trim();
                game.HomePointsScored = Convert.ToInt32(homeScore);
                context.PlayerStats.Where(ps => ps.GameId == game.GameId && ps.PlayerId == game.AwayTeamId).First().PointsAllowed = Convert.ToInt32(homeScore);
                context.SubmitChanges();
                #endregion
                #endregion

                #region Update Player Stats
                Dictionary<int, Dictionary<string, string>> playerStatsData = new Dictionary<int, Dictionary<string, string>>();
                playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Passing");
                playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Rushing");
                playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Receiving");
                playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Fumbles");
                //playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Defensive");
                //playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Kick Returns");
                //playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Punt Returns");
                playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Kicking");
                //playerStatsData = GetPlayerStatsByTable(playerStatsData, dom, "Punting");

                foreach (var ps in playerStatsData)
                {
                    try
                    {
                        //Console.WriteLine(string.Format("{0}:{1}", "Fetching Player", ps.Key));
                        var player = InsertPlayerById(context, ps.Key, game);

                        //Console.WriteLine(string.Format("{0}:{1}", "Converting stats for player", player.Name));
                        var passingCompletionsAttempts = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PASSING", "C/ATT"));
                        var passingCompletions = (passingCompletionsAttempts.Contains("/") ? passingCompletionsAttempts.Split('/')[0].Trim() : "0");
                        var passingAttempts = (passingCompletionsAttempts.Contains("/") ? passingCompletionsAttempts.Split('/')[1].Trim() : "0");
                        var passingYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PASSING", "YDS"));
                        var passingTDS = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PASSING", "TD"));
                        var passingINTS = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PASSING", "INT"));
                        var passingSacks = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PASSING", "SACKS"));
                        var passingSacksTaken = (passingSacks.Contains("-") ? (passingSacks.Split('-')[0].Trim().Equals(string.Empty) ? "0" : passingSacks.Split('-')[0].Trim()) : "0");
                        var passingSackYardsLost = (passingSacks.Contains("-") ? (passingSacks.Split('-')[1].Trim().Equals(string.Empty) ? "0" : passingSacks.Split('-')[1].Trim()) : "0");
                        var rushingCarries = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RUSHING", "CAR"));
                        var rushingYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RUSHING", "YDS"));
                        var rushingTDs = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RUSHING", "TD"));
                        var receivingReceptions = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RECEIVING", "REC"));
                        var receivingYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RECEIVING", "YDS"));
                        var receivingTDs = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RECEIVING", "TD"));
                        var receivingTargets = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "RECEIVING", "TGTS"));
                        var fumbles = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "FUMBLES", "FUM"));
                        var fumblesLost = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "FUMBLES", "LOST"));
                        var fumblesReceovered = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "FUMBLES", "REC"));
                        var totalTackles = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "TOT"));
                        var soloTackles = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "SOLO"));
                        var sacks = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "SACKS"));
                        var tacklesForLoss = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "TFL"));
                        var passesDefended = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "PD"));
                        var qbHits = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "QB HTS"));
                        var defensiveTDs = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "DEFENSIVE", "TD"));
                        var kickReturns = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICK RETURNS", "NO"));
                        var kickReturnYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICK RETURNS", "YDS"));
                        var kickReturnTDs = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICK RETURNS", "TD"));
                        var puntReturns = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PUNT RETURNS", "NO"));
                        var puntReturnYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PUNT RETURNS", "YDS"));
                        var puntReturnTDs = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PUNT RETURNS", "TD"));
                        var fieldGoalsMadeAttempted = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICKING", "FG"));
                        var fieldGoalsMade = (fieldGoalsMadeAttempted.Contains("/") ? fieldGoalsMadeAttempted.Split('/')[0].Trim() : "0");
                        var fieldGoalsAttempted = (fieldGoalsMadeAttempted.Contains("/") ? fieldGoalsMadeAttempted.Split('/')[1].Trim() : "0");
                        var extraPointsMadeAttempted = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICKING", "XP"));
                        var extraPointsMade = (extraPointsMadeAttempted.Contains("/") ? extraPointsMadeAttempted.Split('/')[0].Trim() : "0");
                        var extraPointsAttempted = (extraPointsMadeAttempted.Contains("/") ? extraPointsMadeAttempted.Split('/')[1].Trim() : "0");
                        var kickingPointsScored = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "KICKING", "PTS"));
                        var punts = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PUNTING", "NO"));
                        var puntYards = FindDictionaryStatValue(ps.Value, string.Format("{0}-{1}", "PUNTING", "YDS"));

                        //Console.WriteLine(string.Format("{0}:{1}", "Checking for existing Player Stats for player", player.Name));
                        var playerStats = GeneralScraperMethods.InsertPlayerStatsByPlayerIdGameId(context, player.PlayerId, gameId);
                        GeneralScraperMethods.UpdatePlayerStats(context, playerStats, passingCompletions, passingAttempts, passingYards, passingTDS, passingINTS, passingSacksTaken, passingSackYardsLost, rushingCarries, rushingYards, rushingTDs, receivingReceptions, receivingYards, receivingTDs, receivingTargets, fumbles, fumblesLost, fumblesReceovered, totalTackles, soloTackles, sacks, tacklesForLoss, passesDefended, qbHits, defensiveTDs, kickReturns, kickReturnYards, kickReturnTDs, puntReturns, puntReturnYards, puntReturnTDs, fieldGoalsMade, fieldGoalsAttempted, extraPointsMade, extraPointsAttempted, kickingPointsScored, punts, puntYards);
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                }

                context.SubmitChanges();
                #endregion
            }

            Console.WriteLine("Update Stats By Box Score took " + (DateTime.Now - startDtm).TotalSeconds);
        }