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
- Variables
- func Site(title string) string
- type Category
- type GroupID
- type Groups
- type Production
- func (p *Production) Get(id int) (int, error)
- func (p Production) GithubRepo() string
- func (p Production) Groups() (string, string)
- func (p Production) PouetProd() int
- func (p Production) Released() (int16, int16, int16)
- func (p *Production) Releasers() ([]string, []string, []string, []string)
- func (p Production) SuperType() (tags.Tag, tags.Tag)
- func (p *Production) Unmarshal(r io.Reader) error
- func (p Production) YouTubeVideo() string
- type URI
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 ¶
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"` Credits []struct { Nick struct { Name string `json:"name"` Abbreviation string `json:"abbreviation"` Releaser struct { URL string `json:"url"` ID int `json:"id"` Name string `json:"name"` IsGroup bool `json:"is_group"` } `json:"releaser"` } `json:"nick"` Category string `json:"category"` Role string `json:"role"` } `json:"credits"` // 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 (p *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 (p 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) Groups ¶ added in v0.10.0
func (p Production) Groups() (string, string)
Groups 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.
func (Production) PouetProd ¶
func (p 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) Released ¶ added in v0.10.0
func (p Production) Released() (int16, int16, int16)
Released returns the production's release date as date_issued_ year, month, day values.
func (*Production) Releasers ¶ added in v0.10.0
func (p *Production) Releasers() ([]string, []string, []string, []string)
Authors parses Demozoo authors and reclassifies them into Defacto2 people rolls.
func (Production) SuperType ¶
func (p 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 (p *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 (p 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.