예제 #1
0
 def setTeam(self):
     data = baseball.get('person', {
         'ver': 'v1',
         'personId': self.id,
         'hydrate': ['currentTeam']
     })
     return data.get('people')[0].get('currentTeam')
예제 #2
0
 def setLeagues(self):
     rL = []
     leagues = baseball.get('league', {'ver': 'v1'})
     for l in leagues.get('leagues'):
         if l.get('sport') != None:
             if l.get('sport')['id'] == 1:
                 l = League.League(l)
                 rL.append(l)
     return rL
예제 #3
0
def Sports(id = 1, years = [year]):
    """Main function to generate a Sport object using a LeagueId
    Returns a Sport object
    """

    rData = baseballs.get('sports', {'sportId': id, 'ver': 'v1'})
    sportO = Sport.Sport(rData, years)

    return sportO
예제 #4
0
def Player(id):
    """Main function to generate a Player object using a playerId
    Returns a Player object
    >>>Marcus_Semien = Player(543760)
    >>>print(type(Marcus_Semien))
    <class 'Models.Person.Player'>
    """
    rData = baseballs.get('person', {'personId': id})
    pModel = Person.Player(rData)
    return pModel
예제 #5
0
    def setPlayerList(self, season = [2019]):
        players = baseball.get('sports_players', {'ver': 'v1', 'season': season, 'sportId': self.id })

        """Returns a list of all active players within a sport and list of years
        Default is mlb and 2019"""
        pL= {}
        for y in season:
            players = baseball.get('sports_players', {'ver': 'v1', 'season': y, 'sportId': self.id })
            for dict in players.get('people'):

                for k,v in dict.items():

                    if k == 'id':
                        id = v
                    elif k == 'firstName':
                        first_name = v
                    elif k == 'lastName':
                        if "'" in v:
                            v = v.replace("'", '')

                        last_Name = v
                pL["{} {}".format(first_name, last_Name)] = id
        return pL
예제 #6
0
    def seasonStats(self, type='gameLog'):
        """Returns a player's season/career stats and wether it's hitting or pitching or fielding
            fix and improve this later"""

        #playerInfo = get('people', {'personIds':personId}
        teamStats = baseball.get(
            'person', {
                'ver':
                'v1',
                'personId':
                self.id,
                'hydrate': [
                    'stats(group={},type={})'.format(self.group, type),
                    'currentTeam'
                ]
            })
        return teamStats
예제 #7
0
    def hotColdZones(self, group='hitting', zoneType='onBasePlusSlugging'):
        #find his current team and if he's a hitter or pitcher then
        """Returns ZoneData for player """
        zoneData = baseball.get(
            'person', {
                'ver':
                'v1',
                'personId':
                self.id,
                'hydrate': [
                    'stats(group={},type={})'.format(group, 'hotColdZones'),
                    'currentTeam'
                ]
            })
        zonesData = {}
        sz = StrikeZone.strikeZone('{} {}'.format(self.id, zoneType))
        for stat in zoneData.get('people')[0].get('stats'):
            for types in stat.get('splits'):
                zonesData[types.get('stat')['name']] = types.get(
                    'stat')['zones']
                #create a list of Zones, up to 9
                #using that list of zones make a strike zone
                #make a list of strike zone data for each value
        sz.zoneData = zonesData
        zone = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        zoneLData = []
        for k, v in zonesData.items():
            if k == zoneType:
                for zData in v:
                    if int(zData.get('zone')) > 9:
                        break
                    else:
                        zoneLData.append(float(zData.get('value')))

        sz.updateStrikeZone(zone, zoneLData)
        self.strikeZone = sz
        return sz
예제 #8
0
 def setRoster(self):
     rData = baseball.get('team_roster', {'ver': 'v1', 'teamId': self.id})
     #fix later
     return rData
예제 #9
0
 def setTeams(self):
     teams = baseball.get('teams', {'ver' : 'v1', 'sportIds': self.id})
     return teams
예제 #10
0
    def setRawplayerData(self,season = [2019]):
        for y in season:

            players = baseball.get('sports_players', {'ver': 'v1', 'season': y, 'sportId': self.id })

        return players
예제 #11
0
def Teams(id):
    rData = baseballs.get('teams', {'ver': 'v1', 'teamId': id})
    pModel = Team.Team(rData)
    return pModel