Documentation ¶
Overview ¶
Package demozoo handles the retrieval of production records from the Demozoo API and the extraction of relevant data for the Defacto2 website.
An example of a API v1 production call: As HTML, https://demozoo.org/api/v1/productions/185828/ As JSONP, https://demozoo.org/api/v1/productions/185828/?format=jsonp As JSON, https://demozoo.org/api/v1/productions/185828/?format=json
Index ¶
Constants ¶
const ( ProdURL = "https://demozoo.org/api/v1/productions/" // ProdURL is the base URL for the Demozoo production API. Timeout = 10 * time.Second // HTTP client timeout, Demozoo replies can be slow. Sanity = 450000 // Sanity is to check the maximum permitted production ID. )
const ( Demo = 1 Intro64K = 2 Intro4K = 3 Intro = 4 DiskMag = 5 Tool = 6 MusicDisk = 7 ProductionPack = 9 Intro40K = 10 ChipMusicPack = 12 Cracktro = 13 Music = 14 Intro32b = 15 Intro64b = 16 Intro128b = 18 Intro256b = 19 Intro512b = 20 Intro1K = 21 Intro32K = 22 Game = 33 Intro16K = 35 Intro2K = 37 Intro100K = 39 BBStro = 41 Intro8K = 43 Magazine = 47 TextMag = 49 Intro96K = 50 Intro8b = 54 Intro16b = 55 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Production ¶
type Production struct { // Title is the production title. Title string `json:"title"` // ReleaseDate is the production release date. ReleaseDate string `json:"release_date"` // Supertype is the production type. Supertype string `json:"supertype"` // Authors Authors []struct { Name string `json:"name"` Releaser struct { Name string `json:"name"` IsGroup bool `json:"is_group"` } `json:"releaser"` } `json:"author_nicks"` // Platforms is the production platform. Platforms []struct { Name string `json:"name"` ID int `json:"id"` } `json:"platforms"` // Types is the production type. Types []struct { Name string `json:"name"` ID int `json:"id"` } `json:"types"` // Download links to the remotely hosted files. DownloadLinks []struct { LinkClass string `json:"link_class"` URL string `json:"url"` } `json:"download_links"` // ExternalLinks links to the remotely hosted files. ExternalLinks []struct { LinkClass string `json:"link_class"` URL string `json:"url"` } `json:"external_links"` // ID is the production ID. ID int `json:"id"` }
Production is a Demozoo production record. Only the fields required for the Defacto2 website are included, with everything else being ignored.
func (*Production) Get ¶
func (d *Production) Get(id int) (int, error)
Get requests data for a production record from the Demozoo 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) GithubRepo ¶
func (d Production) GithubRepo() string
GithubRepo returns the Github repository path of the production using the Production struct. It searches the external links for a link class that matches GithubRepo.
func (Production) PouetProd ¶
func (d Production) PouetProd() int
PouetProd returns the Pouet ID of the production using the Production struct. It searches the external links for a link class that matches PouetProduction. A 0 is returned whenever the production does not have a recognized Pouet production link.
func (Production) SuperType ¶
func (d Production) SuperType() (tags.Tag, tags.Tag)
SuperType parses the Demozoo "production", "graphics" and "music" supertypes and returns the corresponding platform and section tags. It returns -1 for an unknown platform or section, in which case the caller should invalidate the Demozoo production.
func (*Production) Unmarshal ¶
func (d *Production) Unmarshal(r io.Reader) error
Unmarshal parses the JSON-encoded data and stores the result in the Production struct. It returns an error if the JSON data is invalid or the production ID is invalid.
func (Production) YouTubeVideo ¶
func (d Production) YouTubeVideo() string
YouTubeVideo returns the ID of a video on YouTube. It searches the external links for a link class that matches YoutubeVideo. An empty string is returned whenever the production does not have a recognized YouTube video link.