labo

package module
v0.0.0-...-472f0fb Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 14 Imported by: 0

README

Nintendo Labo

Labo is a fan project that fetches and wrangles information about the Nintendo Labo product suite. Package draws upon the Nintendo official store and Labo official website to build out the package struct contents. Functions are designed to try collect the contextual information for each Nintendo Labo product and express each edge verbosity. Can be used to build out a basic HTTP API or CLI that can let users lookup Labo information (for example).

Package offers Nintendo Labo information at two levels of detail. A labo.Labo struct contains the common fields for a Nintendo Labo product that is sold on the Nintendo store. The second is the labo.Kit which contains the unique information found on the official website.

Package also offers some basic utils for wrangling the struct data, such as marshalers and unmarshalers. Any contributions are welcome. Is stable for as long as the Nintendo store uses the same page layout.

! Make more Labo's Nintendo !

Nintendo scrape resources
Nintendo store

[https://store.nintendo.com]

Labo official website

[https://labo.nintendo.com]

-- [🗾][🗃️]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(l *Labo) (b []byte)

Marshal marshals a Labo struct into an ordered byte sequence. On error returns an empty byte slice.

func MarshalKit

func MarshalKit(k *Kit) (b []byte)

MarshalKit marshals a Kit struct into an ordered byte sequence. On error returns an empty byte slice.

Types

type Feature

type Feature struct {
	Description string `json:"description"`
	Icon        *Image `json:"icon"`
	Name        string `json:"name"`
}

Feature is a snapshot of a unique Nintendo Labo kit mechanic provided by a Nintendo Labo Toycon.

Features are provided from the official Nintendo Labo website.

type Game

type Game struct {
	Description string `json:"description"`
	Href        *Href  `json:"href"`
	Image       *Image `json:"image"`
	Name        string `json:"name"`
	Title       string `json:"title"`
}

Game is a snapshot of a Nintendo game that is compatible with the Nintendo Labo VR Kit.

type Href

type Href struct {
	IsRelative bool   `json:"is_relative"`
	Link       string `json:"link"`
	Target     string `json:"target"`
	URL        *URL   `json:"URL"`
}

Href is a snapshot of HTTP reference that contains information about a Nintendo Labo product.

type Image

type Image struct {
	Alt      string   `json:"alt"`
	Link     string   `json:"link"`
	URL      *URL     `json:"URL"`
	Variants []*Image `json:"variants"`
}

Image is a snapshot of an image resource belonging to a Nintendo Labo product.

type Kit

type Kit struct {
	Category    string       `json:"category"`
	CategoryID  string       `json:"category_ID"`
	BoxImage    *Image       `json:"box_image"`
	ID          int          `json:"ID"`
	IsVR        bool         `json:"is_VR"`
	Games       []*Game      `json:"games"`
	KitImage    *Image       `json:"kit_image"`
	Language    language.Tag `json:"language"`
	Price       float32      `json:"price"`
	Projects    []*Project   `json:"projects"`
	Retailers   []*Retailer  `json:"retailers"`
	SoftwareBox *Image       `json:"software_box"`
	Status      string       `json:"status"`
	StatusCode  int          `json:"status_code"`
	Toycons     []*Toycon    `json:"toycons"`
	URL         *URL         `json:"URL"`
}

Kit is a Nintendo Labo Kit. Kit structs are built from the Nintendo Labo official website.

Kits contain extended information not found on the Nintendo Labo store and may have varying levels of detail depending on the type of page scraped and the category of the Nintendo Labo kit. Non VR kits will not contain the corresponding VR information.

func GetKit

func GetKit(l *Labo) *Kit

GetKit gets the extended Nintendo Labo Kit information from the official Nintendo Labo website.

The argument Labo must contain a non NIL string Labo.Ref to perform the look-up on the Nintendo Labo website. Some products on the Nintendo Labo store do not contain a official Nintendo Labo website counterpart and will return a non-nil Kit pointer with the HTTP status code and status fields being set to a http.StatusBadRequest. Successful lookups should contain a Labo.StatusCode value of http.StatusOK.

type Labo

type Labo struct {
	Category    string        `json:"category"`
	CategoryID  string        `json:"category_ID"`
	Currency    currency.Unit `json:"currency"`
	Description string        `json:"description"`
	ID          int           `json:"ID"`
	Images      []*Image      `json:"images"`
	Language    language.Tag  `json:"language"`
	Name        string        `json:"name"`
	Parts       []*Part       `json:"parts"`
	Price       float32       `json:"price"`
	ProductID   string        `json:"product_ID"`
	Ref         string        `json:"ref"`
	Status      string        `json:"http_status"`
	StatusCode  int           `json:"http_status_code"`
	Time        time.Time     `json:"time"`
	Title       string        `json:"title"`
	URL         *URL          `json:"URL"`
}

Labo is a Nintendo Labo product. Labo structs may either be a full Nintendo Labo kit or collections of parts.

Nintendo Labo products are provided by the Nintendo store website and contain only surface level data about the Nintendo Labo product.

func Get

func Get(ID string) *Labo

Get gets a specific Nintendo Labo product from the Nintendo Labo store and returns the scraped information as a labo.Labo.

To get a Labo, the Nintendo Labo ID must be provided to the function as a normalized ID. The ID should resemble a sequence of numbers and not contain the product prefix.

Get will always return a labo.Labo, even if the product ID is invalid or not found. To identify whether the corresponding Labo was found, the HTTP status code or HTTP status can be checked. Successfully scraped Labo's will always contain a http.StatusOK.

func GetAllKits

func GetAllKits() []*Labo

GetAllKits gets all Nintendo Labo products that are full kits from the Nintendo store.

func GetAllLabo

func GetAllLabo() []*Labo

GetAllLabo gets all Nintendo Labo products from the Nintendo store.

func GetAllParts

func GetAllParts() []*Labo

GetAllParts get all Nintendo Labo products that are parts and accessories from the Nintendo store.

func Unmarshal

func Unmarshal(b []byte) *Labo

Unmarshal unmarshals a ordered byte sequence.

type Part

type Part struct {
	Amount int    `json:"amount"`
	Color  string `json:"color"`
	Gender string `json:"gender"`
	Href   *Href  `json:"href"`
	Name   string `json:"name"`
	Shape  string `json:"shape"`
	Size   string `json:"size"`
	Spares bool   `json:"spares"`
}

Part is a snapshot of a Nintendo Labo part that is used in the construction of a Nintendo Labo kit.

Parts are built from reading Nintendo Labo product descriptions and contain varying levels of detail and verbosity. A part, depending on the content read, may contain mostly default part amounts, colors, genders, shapes and sizes.

type Project

type Project struct {
	Icon        *Image   `json:"icon"`
	Image       *Image   `json:"image"`
	Name        string   `json:"name"`
	Screenshots []*Image `json:"screenshots"`
}

Project is a snapshot of a Nintendo Labo Kit project that can be built with the contents of a Nintendo Labo kit.

Projects are provided from the Nintendo Labo official website.

type Retailer

type Retailer struct {
	Href  *Href  `json:"href"`
	Image *Image `json:"image"`
	Name  string `json:"name"`
}

Retailer is a snapshot of a first or third party retailer that stocks and sells Nintendo Labo products.

type Toycon

type Toycon struct {
	About       string     `json:"about"`
	Description string     `json:"description"`
	Features    []*Feature `json:"features"`
	Icon        *Image     `json:"icon"`
	Image       *Image     `json:"image"`
	Name        string     `json:"name"`
}

Toycon is a snapshot of a Nintendo Labo Toycon.

Toycon's are the cardboard products built from a Nintendo Labo kit. Each Toycon contains a series of features that are unique to the Nintendo Labo Kit.

type URL

type URL struct {
	Address  string     `json:"address"`
	Fragment string     `json:"fragment"`
	Host     string     `json:"host"`
	Hostname string     `json:"hostname"`
	Path     string     `json:"path"`
	Port     string     `json:"port"`
	Scheme   string     `json:"scheme"`
	Query    url.Values `json:"query"`
}

URL is a snapshot of a URL that relates to a Nintendo Labo resource.

URL's are built from a normal Go *url.URL but expresses the internal properties that are normally returned from the provided struct methods.

Jump to

Keyboard shortcuts

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