mlb

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ARI ...
	ARI = "ARI"
	// ATL ...
	ATL = "ATL"
	// BAL ...
	BAL = "BAL"
	// BOS ...
	BOS = "BOS"
	// CHC ...
	CHC = "CHC"
	// CIN ...
	CIN = "CIN"
	// CLE ...
	CLE = "CLE"
	// COL ...
	COL = "COL"
	// CWS ...
	CWS = "CWS"
	// DET ...
	DET = "DET"
	// HOU ...
	HOU = "HOU"
	// KC ...
	KC = "KC"
	// LAA ...
	LAA = "LAA"
	// LAD ...
	LAD = "LAD"
	// MIA ...
	MIA = "MIA"
	// MIL ...
	MIL = "MIL"
	// MIN ...
	MIN = "MIN"
	// NYM ...
	NYM = "NYM"
	// NYY ...
	NYY = "NYY"
	// OAK ...
	OAK = "OAK"
	// PHI ...
	PHI = "PHI"
	// PIT ...
	PIT = "PIT"
	// SD ...
	SD = "SD"
	// SEA ...
	SEA = "SEA"
	// SF ...
	SF = "SF"
	// STL ...
	STL = "STL"
	// TB ...
	TB = "TB"
	// TEX ...
	TEX = "TEX"
	// TOR ...
	TOR = "TOR"
	// WSH ...
	WSH = "WSH"
)
View Source
const (

	// DateFormat is the game schedule format for querying a particular day from the API
	DateFormat = "2006-01-02"
)

Variables

View Source
var ALL = []string{ARI, ATL, BAL, BOS, CHC, CIN, CLE, COL, CWS, DET, HOU, KC, LAA, LAD, MIA, MIL, MIN, NYM, NYY, OAK, PHI, PIT, SD, SEA, SF, STL, TB, TEX, TOR, WSH}

ALL contains all of the teams in the league

Functions

func GetLiveGame

func GetLiveGame(ctx context.Context, link string) (sportboard.Game, error)

GetLiveGame ...

func GetSeason

func GetSeason(day time.Time) string

GetSeason gets the season identifier based on a date, i.e. 2020

Types

type DefaultLogoConfigs

type DefaultLogoConfigs *[]*logo.Config

DefaultLogoConfigs contains default logo alignedment configurations

type Game

type Game struct {
	GameGetter LiveGameGetter
	ID         int    `json:"gamePk"`
	Link       string `json:"link"`
	Teams      *struct {
		Home *gameTeam `json:"home"`
		Away *gameTeam `json:"away"`
	} `json:"teams"`
	GameTime time.Time
	GameDate string `json:"gameDate"`
	GameData *struct {
		DateTime *struct {
			DateTime string `json:"dateTime,omitempty"`
		} `json:"datetime,omitempty"`
		Status *struct {
			AbstractGameState string `json:"abstractGameState,omitempty"`
			DetailedState     string `json:"detailedState,omitempty"`
			StatusCode        string `json:"statusCode,omitempty"`
		} `json:"status,omitempty"`
		Teams *struct {
			Home *Team `json:"home"`
			Away *Team `json:"away"`
		} `json:"teams"`
	} `json:"gameData,omitempty"`
	LiveData *struct {
		Linescore *struct {
			CurrentInning        int    `json:"currentInning"`
			CurrentInningOrdinal string `json:"currentInningOrdinal"`
			InningState          string `json:"inningState"`
			Teams                *struct {
				Home *gameTeam `json:"home"`
				Away *gameTeam `json:"away"`
			} `json:"teams"`
		} `json:"linescore"`
	} `json:"liveData"`
}

Game ...

func (*Game) AwayTeam

func (g *Game) AwayTeam() (sportboard.Team, error)

AwayTeam ...

func (*Game) GetClock

func (g *Game) GetClock() (string, error)

GetClock represent bottom or top of inning

func (*Game) GetID

func (g *Game) GetID() int

GetID ...

func (g *Game) GetLink() (string, error)

GetLink ...

func (*Game) GetOdds

func (g *Game) GetOdds() (string, string, error)

GetOdds ...

func (*Game) GetQuarter

func (g *Game) GetQuarter() (string, error)

GetQuarter returns the inning

func (*Game) GetStartTime

func (g *Game) GetStartTime(ctx context.Context) (time.Time, error)

GetStartTime ...

func (*Game) GetUpdate

func (g *Game) GetUpdate(ctx context.Context) (sportboard.Game, error)

GetUpdate ...

func (*Game) HomeTeam

func (g *Game) HomeTeam() (sportboard.Team, error)

HomeTeam ...

func (*Game) IsComplete

func (g *Game) IsComplete() (bool, error)

IsComplete ...

func (*Game) IsLive

func (g *Game) IsLive() (bool, error)

IsLive ...

func (*Game) IsPostponed

func (g *Game) IsPostponed() (bool, error)

IsPostponed ...

type LiveGameGetter

type LiveGameGetter func(ctx context.Context, link string) (sportboard.Game, error)

LiveGameGetter is a func used to retrieve an updated sportboard.Game

type MLB

type MLB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MLB implements a sportboard.API

func New

func New(ctx context.Context, logger *zap.Logger) (*MLB, error)

New ...

func (*MLB) AllTeamAbbreviations

func (m *MLB) AllTeamAbbreviations() []string

AllTeamAbbreviations returns a list of all teams in the league

func (*MLB) AvailableStats

func (m *MLB) AvailableStats(ctx context.Context, category string) ([]string, error)

AvailableStats ...

func (*MLB) CacheClear

func (m *MLB) CacheClear(ctx context.Context)

CacheClear ...

func (*MLB) DateStr

func (m *MLB) DateStr(d time.Time) string

DateStr ...

func (*MLB) FindPlayer

func (m *MLB) FindPlayer(ctx context.Context, first string, last string) (statboard.Player, error)

FindPlayer ...

func (m *MLB) GetLogo(ctx context.Context, logoKey string, logoConf *logo.Config, bounds image.Rectangle) (*logo.Logo, error)

GetLogo ...

func (*MLB) GetPlayer

func (m *MLB) GetPlayer(ctx context.Context, id string) (statboard.Player, error)

GetPlayer ...

func (*MLB) GetScheduledGames

func (m *MLB) GetScheduledGames(ctx context.Context, dates []time.Time) ([]sportboard.Game, error)

GetScheduledGames ...

func (*MLB) GetTeams

func (m *MLB) GetTeams(ctx context.Context) ([]sportboard.Team, error)

GetTeams ...

func (*MLB) GetWatchTeams

func (m *MLB) GetWatchTeams(teams []string, season string) []string

GetWatchTeams parses 'ALL' or divisions and adds teams accordingly

func (*MLB) HTTPPathPrefix

func (m *MLB) HTTPPathPrefix() string

HTTPPathPrefix returns the path prefix for the HTTP handlers for this board

func (*MLB) HomeSideSwap added in v0.0.94

func (m *MLB) HomeSideSwap() bool

func (*MLB) League

func (m *MLB) League() string

League ...

func (*MLB) LeagueShortName

func (m *MLB) LeagueShortName() string

LeagueShortName ...

func (*MLB) ListPlayers

func (m *MLB) ListPlayers(ctx context.Context, teamAbbreviation string) ([]statboard.Player, error)

ListPlayers ...

func (*MLB) PlayerCategories

func (m *MLB) PlayerCategories() []string

PlayerCategories returns the possible categories a player falls into

func (*MLB) StatShortName

func (m *MLB) StatShortName(stat string) string

StatShortName returns a short name representation of the stat, if any

func (*MLB) TeamFromID

func (m *MLB) TeamFromID(ctx context.Context, id string) (sportboard.Team, error)

TeamFromID ...

func (*MLB) TeamRank

func (m *MLB) TeamRank(ctx context.Context, team sportboard.Team, season string) string

TeamRank ...

func (*MLB) TeamRecord

func (m *MLB) TeamRecord(ctx context.Context, team sportboard.Team, season string) string

TeamRecord ...

func (*MLB) UpdateGames

func (m *MLB) UpdateGames(ctx context.Context, dateStr string) error

UpdateGames updates scheduled games

func (*MLB) UpdateTeams

func (m *MLB) UpdateTeams(ctx context.Context) error

UpdateTeams ...

type Player

type Player struct {
	Person struct {
		ID       int64  `json:"id"`
		FullName string `json:"fullName"`
		Link     string `json:"link"`
	} `json:"person"`
	PlayerPosition *struct {
		Abbreviation string `json:"abbreviation"`
		Name         string `json:"name"`
	} `json:"position"`
	Stats *playerStats
}

Player ...

func (*Player) FirstName

func (p *Player) FirstName() string

FirstName ...

func (*Player) GetCategory

func (p *Player) GetCategory() string

GetCategory returns the player's catgeory: pitcher or hitter

func (*Player) GetStat

func (p *Player) GetStat(stat string) string

GetStat ...

func (*Player) LastName

func (p *Player) LastName() string

LastName ...

func (*Player) Position

func (p *Player) Position() string

Position ...

func (*Player) PrefixCol

func (p *Player) PrefixCol() string

PrefixCol ...

func (*Player) StatColor

func (p *Player) StatColor(stat string) color.Color

StatColor ...

func (*Player) UpdateStats

func (p *Player) UpdateStats(ctx context.Context) error

UpdateStats ...

type Team

type Team struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	Abbreviation string `json:"abbreviation"`
	Link         string `json:"link,omitempty"`
	DivisionData struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
		Link string `json:"link"`
	} `json:"division"`
	Division *division
	Runs     int
	Roster   []*Player
}

Team implements a sportboard.Team

func GetTeams

func GetTeams(ctx context.Context) ([]*Team, error)

GetTeams ...

func (*Team) ConferenceName

func (t *Team) ConferenceName() string

ConferenceName ...

func (*Team) GetAbbreviation

func (t *Team) GetAbbreviation() string

GetAbbreviation ...

func (*Team) GetDisplayName

func (t *Team) GetDisplayName() string

GetDisplayName ...

func (*Team) GetID

func (t *Team) GetID() string

GetID ...

func (*Team) GetName

func (t *Team) GetName() string

GetName ...

func (*Team) Score

func (t *Team) Score() int

Score ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL