robhowley / nhlscrapi

Python based web scraper API for NHL game data
Apache License 2.0
69 stars 28 forks source link

PlayByPlay missing goal events #21

Open jcnavin opened 3 years ago

jcnavin commented 3 years ago

The following code:

from nhlscrapi.games.game import GameKey, Game, GameType
from nhlscrapi.games.playbyplay import PlayByPlay
from nhlscrapi.games.events import EventType

SEASON = 2020
GAME_TYPE = GameType.Regular
# STL vs WASH 10/2/2019
GAME_ID = 2
EVENT_TYPE = EventType.Goal

# get play by play
pbp = PlayByPlay(game_key=GameKey(SEASON, GAME_TYPE, GAME_ID))

# for every play in pbp, if it's a goal, print it
for play in pbp.plays:
    if play.event.event_type == EVENT_TYPE:
        print(play.event.desc)

Produces the output:

b'STL #9 BLAIS(1), Tip-In, Off. Zone, 8 ft.' b"Assists: #57 PERRON(1); #90 O'REILLY(1)"
b'STL #27 PIETRANGELO(1), Slap, Off. Zone, 38 ft.' b"Assists: #72 FAULK(1); #90 O'REILLY(2)"
b'WSH #9 ORLOV(1), Slap, Off. Zone, 55 ft.' b'Assists: #3 JENSEN(1); #20 ELLER(2)'
b'WSH #13 VRANA(1), Wrist, Off. Zone, 29 ft.' b'Assists: #74 CARLSON(2); #77 OSHIE(1)'

Looking at the box score on either HockeyReference or the NHL website shows there is a missing goal by Alexander Ovechkin scored at the end of the first period. This bug is not idiosyncratic to this game either, I've tested it on the first game of the 2020-2021 season and certain goals are omitted there as well.

I'm on MacOS using Python 3.7.3.

jcnavin commented 3 years ago

I've fixed this--it was a one liner. Sent you a PR.