nhl

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ANA ...
	ANA = "ANA"
	// ARI ...
	ARI = "ARI"
	// BOS ...
	BOS = "BOS"
	// BUF ...
	BUF = "BUF"
	// CAR ...
	CAR = "CAR"
	// CBJ ...
	CBJ = "CBJ"
	// CGY ...
	CGY = "CGY"
	// CHI ...
	CHI = "CHI"
	// COL ...
	COL = "COL"
	// DAL ...
	DAL = "DAL"
	// DET ...
	DET = "DET"
	// EDM ...
	EDM = "EDM"
	// FLA ...
	FLA = "FLA"
	// LAK ...
	LAK = "LAK"
	// MIN ...
	MIN = "MIN"
	// MTL ...
	MTL = "MTL"
	// NJD ...
	NJD = "NJD"
	// NSH ...
	NSH = "NSH"
	// NYI ...
	NYI = "NYI"
	// NYR ...
	NYR = "NYR"
	// OTT ...
	OTT = "OTT"
	// PHI ...
	PHI = "PHI"
	// PIT ...
	PIT = "PIT"
	// SJS ...
	SJS = "SJS"
	// STL ...
	STL = "STL"
	// TBL ...
	TBL = "TBL"
	// TOR ...
	TOR = "TOR"
	// VAN ...
	VAN = "VAN"
	// VGK ...
	VGK = "VGK"
	// WPG ...
	WPG = "WPG"
	// WSH ...
	WSH = "WSH"
)
View Source
const (

	// DateFormat ...
	DateFormat = "2006-01-02"
)

Variables

View Source
var ALL = []string{ANA, ARI, BOS, BUF, CAR, CBJ, CGY, CHI, COL, DAL, DET, EDM, FLA, LAK, MIN, MTL, NJD, NSH, NYI, NYR, OTT, PHI, PIT, SJS, STL, TBL, TOR, VAN, VGK, WPG, WSH}

ALL is a list of all teams in the league

Functions

func GetLiveGame

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

GetLiveGame is a LiveGameGetter

func GetSeason added in v0.0.18

func GetSeason(day time.Time) string

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

Types

type Game

type Game struct {
	GameGetter LiveGameGetter
	ID         int    `json:"gamePk"`
	Link       string `json:"link"`
	Teams      *struct {
		Away *gameTeam `json:"away"`
		Home *gameTeam `json:"home"`
	} `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"`
		} `json:"status,omitempty"`
	} `json:"gameData,omitempty"`
	LiveData *struct {
		Linescore *struct {
			Teams *struct {
				Home *gameTeam `json:"home"`
				Away *gameTeam `json:"away"`
			} `json:"teams"`
			CurrentPeriod              int    `json:"currentPeriod,omitempty"`
			CurrentPeriodOrdinal       string `json:"currentPeriodOrdinal"`
			CurrentPeriodTimeRemaining string `json:"currentPeriodTimeRemaining,omitempty"`
		} `json:"linescore"`
	} `json:"liveData"`
}

Game implements sportboard.Game

func (*Game) AwayTeam

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

AwayTeam ...

func (*Game) GetClock

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

GetClock ...

func (*Game) GetID

func (g *Game) GetID() int

GetID ...

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

GetLink ...

func (*Game) GetOdds added in v0.0.38

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

GetOdds ...

func (*Game) GetQuarter

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

GetQuarter ...

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 added in v0.0.7

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

IsPostponed ...

type LiveGameGetter

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

LiveGameGetter retrieves a live game from a game link

type NHL

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

NHL implements sportboard.API

func New

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

New ...

func (*NHL) AllTeamAbbreviations

func (n *NHL) AllTeamAbbreviations() []string

AllTeamAbbreviations ...

func (*NHL) AvailableStats added in v0.0.18

func (n *NHL) AvailableStats(ctx context.Context, category string) ([]string, error)

AvailableStats ...

func (*NHL) CacheClear added in v0.0.15

func (n *NHL) CacheClear(ctx context.Context)

CacheClear ...

func (*NHL) DateStr

func (n *NHL) DateStr(d time.Time) string

DateStr ...

func (*NHL) FindPlayer added in v0.0.18

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

FindPlayer ...

func (*NHL) Games

func (n *NHL) Games(dateStr string) ([]*Game, error)

Games ...

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

GetLogo ...

func (*NHL) GetPlayer added in v0.0.18

func (n *NHL) GetPlayer(ctx context.Context, id string) (statboard.Player, error)

GetPlayer ...

func (*NHL) GetScheduledGames

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

GetScheduledGames ...

func (*NHL) GetTeams

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

GetTeams ...

func (*NHL) GetWatchTeams added in v0.0.12

func (n *NHL) GetWatchTeams(teams []string, season string) []string

GetWatchTeams ...

func (*NHL) HTTPPathPrefix

func (n *NHL) HTTPPathPrefix() string

HTTPPathPrefix returns the prefix of HTTP calls to this board. i.e. /nhl/foo

func (*NHL) League

func (n *NHL) League() string

League ...

func (*NHL) LeagueShortName added in v0.0.18

func (n *NHL) LeagueShortName() string

LeagueShortName ...

func (*NHL) ListPlayers added in v0.0.18

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

ListPlayers ...

func (*NHL) PlayerCategories added in v0.0.18

func (n *NHL) PlayerCategories() []string

PlayerCategories returns the possible categories a player falls into

func (*NHL) StatShortName added in v0.0.18

func (n *NHL) StatShortName(stat string) string

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

func (*NHL) TeamFromAbbreviation

func (n *NHL) TeamFromAbbreviation(ctx context.Context, abbreviation string) (sportboard.Team, error)

TeamFromAbbreviation ...

func (*NHL) TeamRank added in v0.0.13

func (n *NHL) TeamRank(ctx context.Context, team sportboard.Team, season string) string

TeamRank ...

func (*NHL) TeamRecord added in v0.0.13

func (n *NHL) TeamRecord(ctx context.Context, team sportboard.Team, season string) string

TeamRecord ...

func (*NHL) UpdateGames

func (n *NHL) UpdateGames(ctx context.Context, dateStr string) error

UpdateGames ...

func (*NHL) UpdateTeams

func (n *NHL) UpdateTeams(ctx context.Context) error

UpdateTeams ...

type Player added in v0.0.18

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 added in v0.0.18

func (p *Player) FirstName() string

FirstName ...

func (*Player) GetCategory added in v0.0.18

func (p *Player) GetCategory() string

GetCategory returns the player's catgeory: skater or goalie

func (*Player) GetStat added in v0.0.18

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

GetStat ...

func (*Player) LastName added in v0.0.18

func (p *Player) LastName() string

LastName ...

func (*Player) Position added in v0.0.18

func (p *Player) Position() string

Position ...

func (*Player) PrefixCol added in v0.0.20

func (p *Player) PrefixCol() string

PrefixCol ...

func (*Player) StatColor added in v0.0.20

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

StatColor ...

func (*Player) UpdateStats added in v0.0.18

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"`
	NextGameSchedule *struct {
		Dates []*struct {
			Games []*Game `json:"games"`
		} `json:"dates"`
	} `json:"nextGameSchedule,omitempty"`
	DivisionData struct {
		ID int `json:"id"`
	} `json:"division"`
	Roster struct {
		Roster []*Player `json:"roster"`
	} `json:"roster"`
	Division *division
	// contains filtered or unexported fields
}

Team implements sportboard.Team

func GetTeams

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

GetTeams ...

func (*Team) ConferenceName added in v0.0.41

func (t *Team) ConferenceName() string

ConferenceName ...

func (*Team) GetAbbreviation

func (t *Team) GetAbbreviation() string

GetAbbreviation ...

func (*Team) GetDisplayName added in v0.0.41

func (t *Team) GetDisplayName() string

GetDisplayName ...

func (*Team) GetID

func (t *Team) GetID() int

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