Documentation ¶
Overview ¶
Package pouet provides production, user voting data sourced from the Pouet website API.
Index ¶
Constants ¶
const ( ProdURL = "https://api.pouet.net/v1/prod/?id=" // ProdURL is the base URL for the Pouet production API. StarRounder = 0.5 // StarRounder is the rounding value for the stars rating. Sanity = 200000 // Sanity is to check the maximum permitted production ID. )
Variables ¶
Functions ¶
func PlatformsValid ¶
func Stars ¶
Stars returns the number of stars for the average votes. The value of votesAvg must be a valid float64 value and not greater than 1.0.
func TypesValid ¶
Types ¶
type Platforms ¶
type Platforms struct { DosGus Platform `json:"69"` // MS-Dos with GUS Windows Platform `json:"68"` // Windows MSDos Platform `json:"67"` // MS-Dos }
Platforms are the supported platforms from the Pouet API.
type Production ¶
type Production struct { ID int `json:"id"` // ID is the prod ID. Title string `json:"title"` // Title is the prod title. ReleaseDate string `json:"release_date"` // ReleaseDate is the prod release date. Download string `json:"download"` // Download is the first download link. Demozoo string `json:"demozoo"` // Demozoo is the Demozoo identifier. Groups []struct { ID string `json:"id"` Name string `json:"name"` } `json:"groups"` // Groups are the releasers that produced the prod. Platforms Platforms `json:"platforms"` // Platforms are the platforms the prod runs on. Platform string `json:"platform"` // Platform is the prod platforms as a string. Types Types `json:"types"` // Types are the prod types. Links []struct { Type string `json:"type"` Link string `json:"link"` } `json:"downloads"` // Downloads are the additional download links. Valid bool `json:"valid"` // Valid is true if this prod is a supported type and platform. }
Production is the production data from the Pouet API. The Pouet API returns values as null or string, so this struct is used to normalize the data types.
func (*Production) Get ¶
func (p *Production) Get(id int) (int, error)
Get requests data for a production record from the Pouet API. It returns an error if the production ID is invalid, when the request reaches a [Timeout] or fails. A status code is returned when the response status is not OK.
func (Production) PlatformType ¶
func (p Production) PlatformType() (tags.Tag, tags.Tag)
PlatformType parses the Pouet "platform" and "type" data and returns the corresponding platform and section tags. It returns -1 for an unknown platform or section.
func (Production) Released ¶
func (p Production) Released() (int16, int16, int16)
Released returns the production's release date as date_issued_ year, month, day values.
func (Production) Releasers ¶
func (p Production) Releasers() (string, string)
Releasers returns the first two names in the production that have is_group as true. The one exception is if the production title contains a reference to a BBS or FTP site name. Then that title will be used as the first group returned.
type Response ¶
type Response struct { Prod struct { ID string `json:"id"` // ID is the prod ID. Title string `json:"name"` // Title is the prod title. ReleaseDate string `json:"releaseDate"` // ReleaseDate is the prod release date. Voteup string `json:"voteup"` // Voteup is the number of thumbs up votes. Votepig string `json:"votepig"` // Votepig is the number of meh votes. Votedown string `json:"votedown"` // Votedown is the number of thumbs down votes. Voteavg string `json:"voteavg"` // Voteavg is the average votes, the maximum value is 1.0. Download string `json:"download"` // Download is the first download link. Demozoo string `json:"demozoo"` // Demozoo is the first Demozoo link. Groups []struct { ID string `json:"id"` Name string `json:"name"` } `json:"groups"` // Groups are the releasers that produced the prod. Platforms Platforms `json:"platforms"` // Platforms are the platforms the prod runs on. Types Types `json:"types"` // Types are the prod types. DownloadLinks []struct { Type string `json:"type"` Link string `json:"link"` } `json:"downloadLinks"` // DownloadLinks are the additional download links. } `json:"prod"` // Prod is the production data. Success bool `json:"success"` // Success is true if the prod data was found. }
Response is the JSON response from the Pouet API with production voting data.
type Votes ¶
type Votes struct { // ID is the production ID. ID int `json:"id"` // Stars is the production rating using the average votes multiplied by 5. Stars float64 `json:"stars"` // VotesAvg is the average votes, the maximum value is 1.0. VotesAvg float64 `json:"votes_avg"` // VotesUp is the number of thumbs up votes. VotesUp uint64 `json:"votes_up"` // VotesMeh is the number of meh votes otherwise called piggies. VotesMeh uint64 `json:"votes_meh"` // VotesDown is the number of thumbs down votes. VotesDown uint64 `json:"votes_down"` }
Votes is the production voting data from the Pouet API. The Pouet API returns values as null or string, so this struct is used to normalize the data types.