prods

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package prods handles marshalling of a Demozoo Production.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filename

func Filename(h http.Header) string

Filename is obtained from the http header metadata.

func Mutate

func Mutate(u *url.URL) (*url.URL, error)

Mutate applies fixes to known problematic URLs.

func Parse

func Parse(rawURL string) (int, error)

Parse takes a Pouet prod URL and extracts the ID.

func RandomName

func RandomName() (string, error)

RandomName generates a random temporary filename.

func SaveName

func SaveName(rawURL string) (string, error)

SaveName gets a filename from the URL or generates a random filename.

Types

type Authors

type Authors struct {
	Text  []string // credit_text, writer
	Code  []string // credit_program, programmer/coder
	Art   []string // credit_illustration, artist/graphics
	Audio []string // credit_audio, musician/sound
}

Authors contains Defacto2 people rolls.

type Category

type Category int

Category are tags for production imports.

const (
	Text     Category = iota // Text based files.
	Code                     // Code are binary files.
	Graphics                 // Graphics are images.
	Music                    // Music is audio.
	Magazine                 // Magazine are publications.
)

func (Category) String

func (c Category) String() string

type DownloadsAPIv1

type DownloadsAPIv1 struct {
	LinkClass string `json:"link_class"`
	URL       string `json:"url"`
}

DownloadsAPIv1 are DownloadLinks for ProductionsAPIv1.

type ProductionsAPIv1

type ProductionsAPIv1 struct {
	URL         string `json:"url"`
	DemozooURL  string `json:"demozoo_url"`
	ID          int    `json:"id"`
	Title       string `json:"title"`
	AuthorNicks []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:"author_nicks"`
	AuthorAffiliationNicks []any  `json:"author_affiliation_nicks"`
	ReleaseDate            string `json:"release_date"`
	Supertype              string `json:"supertype"`
	Platforms              []struct {
		URL  string `json:"url"`
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"platforms"`
	Types []struct {
		URL       string `json:"url"`
		ID        int    `json:"id"`
		Name      string `json:"name"`
		Supertype string `json:"supertype"`
	} `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"`
	DownloadLinks []struct {
		LinkClass string `json:"link_class"`
		URL       string `json:"url"`
	} `json:"download_links"`
	ExternalLinks []struct {
		LinkClass string `json:"link_class"`
		URL       string `json:"url"`
	} `json:"external_links"`
	ReleaseParties      []any `json:"release_parties"`
	CompetitionPlacings []any `json:"competition_placings"`
	InvitationParties   []any `json:"invitation_parties"`
	Screenshots         []struct {
		OriginalURL     string `json:"original_url"`
		OriginalWidth   int    `json:"original_width"`
		OriginalHeight  int    `json:"original_height"`
		StandardURL     string `json:"standard_url"`
		StandardWidth   int    `json:"standard_width"`
		StandardHeight  int    `json:"standard_height"`
		ThumbnailURL    string `json:"thumbnail_url"`
		ThumbnailWidth  int    `json:"thumbnail_width"`
		ThumbnailHeight int    `json:"thumbnail_height"`
	} `json:"screenshots"`
}

ProductionsAPIv1 productions API v1. This can be dynamically generated at https://mholt.github.io/json-to-go/ Get the Demozoo JSON output from https://demozoo.org/api/v1/productions/{{.ID}}/?format=json

func (*ProductionsAPIv1) Authors

func (p *ProductionsAPIv1) Authors() Authors

Authors parses Demozoo authors and reclassifies them into Defacto2 people rolls.

func (*ProductionsAPIv1) Download

func (p *ProductionsAPIv1) Download(w io.Writer, l DownloadsAPIv1) error
func (p *ProductionsAPIv1) DownloadLink(w io.Writer) (string, string)

DownloadLink parses the Demozoo DownloadLinks to return the filename and link of the first suitable download.

func (*ProductionsAPIv1) Downloads

func (p *ProductionsAPIv1) Downloads(w io.Writer)

Downloads parses the Demozoo DownloadLinks and saves the first suitable download.

func (*ProductionsAPIv1) JSON

func (p *ProductionsAPIv1) JSON() ([]byte, error)

JSON returns the production API results as tabbed JSON. This is used by internal/generator.go.

func (*ProductionsAPIv1) PouetID

func (p *ProductionsAPIv1) PouetID(ping bool) (
	id int, code int, err error,
)

PouetID returns the ID value used by Pouet's "which prod" URL query and if ping is enabled, the received HTTP status code. example: https://www.pouet.net/prod.php?which=30352

func (*ProductionsAPIv1) Print

func (p *ProductionsAPIv1) Print(w io.Writer) error

Print to the writer the production API results as tabbed JSON.

Jump to

Keyboard shortcuts

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