nhl

package
v0.0.91 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 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

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

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

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

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

AvailableStats ...

func (*NHL) CacheClear

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

CacheClear ...

func (*NHL) DateStr

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

DateStr ...

func (*NHL) FindPlayer

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

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

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

GetWatchTeams returns a list of team ID's

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

func (n *NHL) LeagueShortName() string

LeagueShortName ...

func (*NHL) ListPlayers

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

ListPlayers ...

func (*NHL) PlayerCategories

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

PlayerCategories returns the possible categories a player falls into

func (*NHL) StatShortName

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

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

func (*NHL) TeamFromID

func (n *NHL) TeamFromID(ctx context.Context, id string) (sportboard.Team, error)

TeamFromID ...

func (*NHL) TeamRank

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

TeamRank ...

func (*NHL) TeamRecord

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

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: skater or goalie

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"`
	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 (*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