pouet

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pouet provides production, user voting data sourced from the Pouet website API.

Index

Constants

View Source
const (
	// ProdURL is the base URL for the Pouet production API.
	ProdURL = "https://api.pouet.net/v1/prod/?id="
	// Timeout is the HTTP client timeout.
	Timeout = 5 * time.Second
	// StarRounder is the rounding value for the stars rating.
	StarRounder = 0.5
	// Sanity is to check the maximum permitted production ID.
	Sanity = 200000
)

Variables

View Source
var (
	ErrID      = errors.New("pouet production id is invalid")
	ErrSuccess = errors.New("pouet production not found")
	ErrStatus  = errors.New("pouet production status is not ok")
)

Functions

func Stars

func Stars(up, ok, down uint64) float64

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.

Types

type Platf

type Platf struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Platf is the production platform data from the Pouet API.

type Platfs

type Platfs struct {
	DosGus  Platf `json:"69"` // MS-Dos with GUS
	Windows Platf `json:"68"` // Windows
	MSDos   Platf `json:"67"` // MS-Dos
}

Platfs are the supported platforms from the Pouet API.

func (Platfs) String

func (p Platfs) String() string

func (Platfs) Valid

func (p Platfs) Valid() bool

type Production

type Production struct {
	// Platforms are the platforms the prod runs on.
	Platforms Platfs `json:"platforms"`
	// Title is the prod title.
	Title string `json:"title"`
	// ReleaseDate is the prod release date.
	ReleaseDate string `json:"release_date"`
	// Platform is the prod platforms as a string.
	// If the string is empty then the prod is not supported.
	Platform string `json:"platform"`
	// Groups are the releasers that produced the prod.
	Groups []struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"groups"`
	// Types are the prod types.
	Types Types `json:"types"`
	// ID is the prod ID.
	ID int `json:"id"`
	// Valid is true if this prod is a supported type and platform.
	Valid bool `json:"valid"`
}

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) Uploader

func (p *Production) Uploader(id int) error

Uploader retrieves and parses the production data from the Pouet API. The id value is the Pouet production ID and must be greater than 0. The data is intended for the Pouet Uploader.

type Response

type Response struct {
	Prod struct {
		ID          string `json:"id"`          // ID is the prod ID.
		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.
		Title       string `json:"name"`        // Title is the prod title.
		ReleaseDate string `json:"releaseDate"` // ReleaseDate is the prod release date.
		Groups      []struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"groups"` // Groups are the releasers that produced the prod.
		Platfs        Platfs `json:"platforms"` // Platforms are the platforms the prod runs on.
		Types         Types  `json:"types"`     // Types are the prod types.
		Download      string `json:"download"`  // Download is the first download link.
		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.

func (*Response) Get

func (r *Response) Get(id int) error

Get retrieves the production voting data from the Pouet API. The id value is the Pouet production ID and must be greater than 0.

type Type

type Type string

Type is the production type from the Pouet API.

func (Type) Valid

func (t Type) Valid() bool

type Types

type Types []Type

Types are the production types from the Pouet API.

func (Types) String

func (t Types) String() string

func (Types) Valid

func (t Types) Valid() bool

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.

func (*Votes) Votes

func (v *Votes) Votes(id int) error

Votes retrieves the production voting data from the Pouet API. The id value is the Pouet production ID and must be greater than 0. The data is intended for the Artifact page, Pouët reviews section.

Jump to

Keyboard shortcuts

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