gdb

package
Version: v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: MIT Imports: 5 Imported by: 15

Documentation

Overview

Package gdb interacts with thegamedb.net's API.

Example:

resp, err := gdb.GetGame(GGReq{ID: "5"})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUp

func IsUp(ctx context.Context) bool

IsUp returns if thegamedb.net is up.

Types

type GGLReq

type GGLReq struct {
	Name     string
	Platform string
	Genre    string
}

GGLReq represents a request for a GetGameList command.

type GGLResp

type GGLResp struct {
	XMLName xml.Name
	Game    []GameTrunc
	Err     string `xml:",chardata"`
}

GGLResp represents the response of a GetGameList command.

func GetGameList

func GetGameList(ctx context.Context, req GGLReq) (*GGLResp, error)

GetGameList gets the game information from the DB.

type GGReq

type GGReq struct {
	ID       string
	Name     string
	Platform string
}

GGReq is the request to GetGame.

type GGResp

type GGResp struct {
	XMLName  xml.Name
	ImageURL string `xml:"baseImgUrl"`
	Game     []Game
	Err      string `xml:",chardata"`
}

GGResp is the response of the GetGame query.

func GetGame

func GetGame(ctx context.Context, req GGReq) (*GGResp, error)

GetGame gets the game information from the DB.

type Game

type Game struct {
	ID          string `xml:"id"`
	GameTitle   string
	Overview    string
	ReleaseDate string
	Platform    string
	Developer   string
	Publisher   string
	Genres      []string `xml:"Genres>genre"`
	Players     string
	Rating      float64
	ESRB        string
	AltTitles   []string `xml:"AlternateTitles>title"`
	BoxArt      []Image  `xml:"Images>boxart"`
	Banner      []Image  `xml:"Images>banner"`
	FanArt      []OImage `xml:"Images>fanart"`
	Screenshot  []OImage `xml:"Images>screenshot"`
}

Game is used to parse the GetGame's <Game> tag.

type GameTrunc

type GameTrunc struct {
	ID          string `xml:"id"`
	GameTitle   string
	ReleaseDate string
	Platform    string
}

GameTrunc is used to parse the GetGamesList's <Game> tag.

type Image

type Image struct {
	URL    string `xml:",chardata"`
	Width  uint   `xml:"width,attr"`
	Height uint   `xml:"height,attr"`
	// Only used on boxart.
	Side  string `xml:"side,attr"`
	Thumb string `xml:"thumb,attr"`
}

Image is used to parse the GetGame's <Images> tags.

type OImage

type OImage struct {
	Original Image  `xml:"original"`
	Thumb    string `xml:"thumb"`
}

OImage is used to parse <Images> tags for fanart and screenshots since they are formatted differently.

Source Files

Jump to

Keyboard shortcuts

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