panzarino / mlbgame

A Python API to retrieve and read MLB GameDay data
http://panz.io/mlbgame/
MIT License
527 stars 112 forks source link

Arizona team name discrepency between mlbgame division standings and games #109

Closed ghost closed 6 years ago

ghost commented 6 years ago

mlbgame version == 2.5.0 on Python 3.6

I'm attempting to correlate a team gathered from the mlbgame.standings().divisions list and report on today's game using mlbgame.day(datetime.now()...). When trying to match a game using either home or away team's name, the games for Arizona use D-backs whereas the divisional standings objects are using the name of Diamondbacks. I added a quick hack in my module to workaround this but it seems like they really should be the same?

If this is just from MLB's own API, looks like it's something at least worth documenting for users must keep in mind when trying to compare the two datasets.

to demonstrate, see my method below:

    def find_team_by_name(self, name):
        for division in self.divisions:
            for team in division.teams:
                print('{} in {} ?'.format(name, team.team_full))
                if name in team.team_full:
                    return team
        print('no team found?')
        return None
# from test output
                other_team = self.find_team_by_name(name=real_team_name)
>               game_text = self.format_away_team(home_team=other_team.team_abbrev)
E               AttributeError: 'NoneType' object has no attribute 'team_abbrev'
...
----------------------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------------------
Phillies in Philadelphia Phillies ?
Nationals in Atlanta Braves ?
Nationals in Philadelphia Phillies ?
Nationals in Washington Nationals ?
D-backs in Atlanta Braves ?
D-backs in Philadelphia Phillies ?
D-backs in Washington Nationals ?
D-backs in New York Mets ?
D-backs in Miami Marlins ?
D-backs in Chicago Cubs ?
D-backs in Milwaukee Brewers ?
D-backs in St. Louis Cardinals ?
D-backs in Pittsburgh Pirates ?
D-backs in Cincinnati Reds ?
D-backs in Colorado Rockies ?
D-backs in Los Angeles Dodgers ?
D-backs in Arizona Diamondbacks ?
D-backs in San Francisco Giants ?
D-backs in San Diego Padres ?
D-backs in Boston Red Sox ?
D-backs in New York Yankees ?
D-backs in Tampa Bay Rays ?
D-backs in Toronto Blue Jays ?
D-backs in Baltimore Orioles ?
D-backs in Cleveland Indians ?
D-backs in Minnesota Twins ?
D-backs in Detroit Tigers ?
D-backs in Chicago White Sox ?
D-backs in Kansas City Royals ?
D-backs in Houston Astros ?
D-backs in Oakland Athletics ?
D-backs in Seattle Mariners ?
D-backs in Los Angeles Angels ?
D-backs in Texas Rangers ?
no team found?
panzarino commented 6 years ago

@tomcooperca This is an issue with the way that MLB reports the data and is not an issue with mlbgame. Therefore, there is not much I can do to fix the inconsistency, but I can add a note somewhere in the docs.