nhlgc

package module
v0.0.0-...-17a5fd8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2014 License: BSD-2-Clause Imports: 15 Imported by: 0

README

nhlgc

nhlgc is a Go library for interacting with the NHL GameCenter API. It is currently focused on consuming video streams.

Usage is simple:

import(
	"github.com/timewasted/nhlgc"
	// Your other imports here
	// ...
)

gameCenter := nhlgc.New()
if err := gameCenter.Login(config.Username, config.Password); err != nil {
	panic(err)
}

games, err := gameCenter.GetTodaysGames()
if err != nil {
	panic(err)
}

playlists, err := gameCenter.GetVideoPlaylists(games.Games[0].Season, games.Games[0].ID, nhlgc.HomeTeamPlaylist)
if err != nil {
	panic(err)
}

playlist, err := gameCenter.GetStreamPlaylist(playlists[0])
if err != nil {
	panic(err)
}

License:

Copyright (c) 2014, Ryan Rogers
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: 

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Overview

Package nhlgc is a library that interacts with the NHL GameCenter API.

Index

Constants

View Source
const (
	StreamTypeArchive   = "archive"
	StreamTypeCondensed = "condensed"
	StreamTypeDVR       = "dvr"
	StreamTypeLive      = "live"
)

Valid stream types for the publishPoint API endpoint.

View Source
const (
	StreamSourceHome   = "2"
	StreamSourceAway   = "4"
	StreamSourceFrench = "8"
)

Stream sources.

View Source
const (
	SeasonTypePre  = "01"
	SeasonTypeReg  = "02"
	SeasonTypePost = "03"
)

Season type identifiers.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByHighestBandwidth

type ByHighestBandwidth []StreamPlaylist

func (ByHighestBandwidth) Len

func (a ByHighestBandwidth) Len() int

func (ByHighestBandwidth) Less

func (a ByHighestBandwidth) Less(i, j int) bool

func (ByHighestBandwidth) Swap

func (a ByHighestBandwidth) Swap(i, j int)

type DecryptionParameters

type DecryptionParameters struct {
	Method   string
	Sequence uint64
	Key, IV  []byte
}

type GameDetails

type GameDetails struct {
	GID           string         `xml:"gid"`
	Season        string         `xml:"season"`
	Type          string         `xml:"type"`
	ID            string         `xml:"id"`
	Date          GameTimeGMT    `xml:"date"`
	GameStartTime GameTimeGMT    `xml:"gameTimeGMT"`
	GameEndTime   GameTimeGMT    `xml:"gameEndTimeGMT"`
	HomeTeam      string         `xml:"homeTeam"`
	AwayTeam      string         `xml:"awayTeam"`
	HomeGoals     OptionalUint64 `xml:"homeGoals"`
	AwayGoals     OptionalUint64 `xml:"awayGoals"`
	Blocked       bool           `xml:"blocked"`
	GameState     string         `xml:"gameState"`
	Result        string         `xml:"result"`
	IsLive        bool           `xml:"isLive"`
	PublishPoint  string         `xml:"program>publishPoint"`
}

type GameHighlight

type GameHighlight struct {
	ID           string `json:"id"`
	PublishPoint string `json:"publishPoint"`
}

type GameHighlights

type GameHighlights map[string]GameHighlight

type GameInfo

type GameInfo struct {
	Game GameDetails `xml:"game"`
}

type GamePublishPoint

type GamePublishPoint struct {
	Path string `xml:"path"`
}

type GameTimeGMT

type GameTimeGMT time.Time

func (*GameTimeGMT) String

func (gt *GameTimeGMT) String() string

func (*GameTimeGMT) UnmarshalXML

func (gt *GameTimeGMT) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type GamesList

type GamesList struct {
	Games []GameDetails `xml:"games>game"`
}

type LogicError

type LogicError struct {
	// contains filtered or unexported fields
}

func (LogicError) Error

func (e LogicError) Error() string

type NHLGameCenter

type NHLGameCenter struct {
	// contains filtered or unexported fields
}

func New

func New() *NHLGameCenter

New returns an instance of NHLGameCenter.

func (*NHLGameCenter) GetGameDetails

func (gc *NHLGameCenter) GetGameDetails(season, gameID string) (game GameDetails, err error)

GetGameDetails retrieves details about the specified game.

func (*NHLGameCenter) GetGameHighlights

func (gc *NHLGameCenter) GetGameHighlights(season, gameID string) (highlights GameHighlights, err error)

GetGameHighlights retrieves URLs for highlight videos for the specified game. The return value is a map, where the key is a label for the source of the highlight. For example:

highlights := GameHighlights{
	"home": GameHighlight{
		PublishPoint: "http://example.com/home-highlights",
	},
	"away": GameHighlight{
		PublishPoint: "http://example.com/away-highlights",
	},
	"french": GameHighlight{
		PublishPoint: "http://example.com/highlights-in-french",
	},
}

func (*NHLGameCenter) GetGamePlaylists

func (gc *NHLGameCenter) GetGamePlaylists(season, gameID, streamType, streamSource string) (playlists []StreamPlaylist, err error)

GetGamePlaylists retrieves and parses the master playlist for the specified game. This playlist will generally contain multiple media playlists of varying stream quality.

func (*NHLGameCenter) GetMediaPlaylist

func (gc *NHLGameCenter) GetMediaPlaylist(master StreamPlaylist) (media StreamPlaylist, err error)

GetMediaPlaylist retrieves and parses the media playlist referenced by the specified master playlist.

func (*NHLGameCenter) GetPlaylistsFromURL

func (gc *NHLGameCenter) GetPlaylistsFromURL(reqUrl string) (playlists []StreamPlaylist, err error)

GetPlaylistsFromURL retrieves and parses a M3U8 object from the specified URL. The return value is a list of master or media playlists.

func (*NHLGameCenter) GetRecentGames

func (gc *NHLGameCenter) GetRecentGames() (GamesList, error)

GetRecentGames retrieves a list of recent and upcoming games.

func (*NHLGameCenter) GetStreamDecryptionParameters

func (gc *NHLGameCenter) GetStreamDecryptionParameters(media StreamPlaylist) (params []DecryptionParameters, err error)

GetStreamDecryptionParameters reads the specified media playlist and returns the parameters required to decrypt each video segment.

func (*NHLGameCenter) GetTodaysGames

func (gc *NHLGameCenter) GetTodaysGames() (GamesList, error)

GetTodaysGames retrieves a list of games that take place today.

func (*NHLGameCenter) Login

func (gc *NHLGameCenter) Login(username, password string, rogers bool) error

Login logs into NHL GameCenter using the specified credentials. The 'rogers' parameter should be true when using a Rogers internet login.

type NetworkError

type NetworkError struct {
	LogicError
	StatusCode int
	Location   string
}

func (NetworkError) Error

func (e NetworkError) Error() string

type OptionalUint64

type OptionalUint64 uint64

func (*OptionalUint64) UnmarshalXML

func (o *OptionalUint64) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type StreamPlaylist

type StreamPlaylist struct {
	RawFile   string
	M3U8      m3u8.Playlist
	URL       *url.URL
	Bandwidth uint32
}

Jump to

Keyboard shortcuts

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