resource

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Represents all the data to be fetched related to a given mod. Used to cache the data, instead of repeatedly accessing it again and again.

Initialise using ResourceFromID or ResourceFromURL.

Get values using the methods named after the fields.

func ResourceFromID

func ResourceFromID[T constraints.Integer](id T) Resource

func ResourceFromURL

func ResourceFromURL[T ~string](url T) Resource

func (*Resource) Breadcrumbs

func (r *Resource) Breadcrumbs() ([]string, error)

The stuff above the workshop title, e.g. "Game> Workshop > User's Workshop" for a single entry.

func (*Resource) Doc

func (r *Resource) Doc() (*goquery.Document, error)

If already fetched, it'll reuse the version stored in memory. Otherwise, it'll download the page, parse it into a Goquery document and store that in memory, then give it to you.

func (*Resource) Game added in v1.3.1

func (r *Resource) Game() (string, error)

Gets the game listed

func (*Resource) ID

func (r *Resource) ID() (int, error)

If and ID has been given, it will return that. Otherwise, it will attempt to parse it from the given URL.

func (*Resource) Timestamp

func (r *Resource) Timestamp() (string, error)

Gets the timestamp of when last updated as a string, unparsed.

func (*Resource) Title

func (r *Resource) Title() (string, error)

Gets the name of the mod from the web page's title header.

func (*Resource) URL

func (r *Resource) URL() (string, bool)

If a URL has been given, it will return that. Otherwise, it will construct one using the given ID.

func (*Resource) Updated

func (r *Resource) Updated() (time.Time, error)

Parses the string timestamp gotten from Timestamp()

Jump to

Keyboard shortcuts

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