goidgames

package module
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	API_URL       = "https://www.doomworld.com/idgames/api/api.php?"
	ACTION        = "action"
	ACTION_GET    = "get"
	ACTION_SEARCH = "search"
	ACTION_LATEST = "latestfiles"
	OUT           = "out"
	OUT_JSON      = "json"
	OUT_XML       = "xml"

	SEARCH_TYPE_FILENAME    = "filename"
	SEARCH_TYPE_TITLE       = "title"
	SEARCH_TYPE_AUTHOR      = "author"
	SEARCH_TYPE_EMAIL       = "email"
	SEARCH_TYPE_DESCRIPTION = "description"
	SEARCH_TYPE_CREDITS     = "credits"
	SEARCH_TYPE_EDITORS     = "editors"
	SEARCH_TYPE_TEXTFILE    = "textfile"

	SEARCH_SORT_DATE     = "date"
	SEARCH_SORT_FILENAME = "filename"
	SEARCH_SORT_SIZE     = "size"
	SEARCH_SORT_RATING   = "rating"

	SEARCH_SORT_ASC  = "asc"
	SEARCH_SORT_DESC = "desc"
)

Variables

View Source
var (
	Mirrors = []string{"https://www.quaddicted.com/files/idgames", "https://ftpmirror1.infania.net/pub/idgames"}
)

Functions

This section is empty.

Types

type Idgame

type Idgame struct {
	Id          int      `json:"id"`          // The file's id.
	Title       string   `json:"title"`       // The title of the file.
	Dir         string   `json:"dir"`         // The file's full directory path.
	Filename    string   `json:"filename"`    // The filename itself, no path.
	Size        int      `json:"size"`        // The size of the file in bytes.
	Age         int64    `json:"age"`         // The date that the file was added in seconds since the Unix Epoch (Jan. 1, 1970). Note: This is likely influenced by the time zone of the primary idGames Archive.
	Date        string   `json:"date"`        // A YYYY-MM-DD formatted date describing the date that this file was added to the archive.
	Author      string   `json:"author"`      // The file's author/uploader.
	Email       string   `json:"email"`       // The author's E-mail address.
	Description string   `json:"description"` // The file's description.
	Credits     string   `json:"credits"`     // The file's additional credits.
	Base        string   `json:"base"`        // The file's base (from another mod? made from scratch?).
	Buildtime   string   `json:"buildtime"`   // The file's/WAD's build time.
	Editors     string   `json:"editors"`     // The editors used to create this.
	Bugs        string   `json:"bugs"`        // Known bugs (if any).
	Textfile    string   `json:"textfile"`    // The file's text file contents.
	Rating      float32  `json:"rating"`      // The file's average rating, as rated by users.
	Votes       int      `json:"votes"`       // The number of votes that this file received.
	Url         string   `json:"url"`         // The URL for the idGames Archive page for this file.
	Idgamesurl  string   `json:"idgamesurl"`  // The idgames protocol URL for this file.
	Reviews     []Review `json:"reviews"`     // The element that contains all reviews for this file in review elements.
}

Idgame represents the metadata returned by the idgames api.

func Get

func Get(id int, filepath string) (g Idgame, err error)

Get gets the data for a game specified by id or filepath. Pass an empyt string for not used paramters.

func LatestFiles

func LatestFiles(limit, startid int) (idgames []Idgame, err error)

LatestFiles returns a slice of the latest additions to idgames. Limit the number or start from a specific Id. Pass 0 as startid if you want to see the hottest and newest files. If the limit is higher then the APIs max, then this is silently ignored.

func Search(query, searchType, sort, sortOrder string) (idgames []Idgame, err error)

Search searches for games based on the query. It returns a slice with results. Types can be found as constant. searchType, sort and sortOrder can be one of the constants or an empty string. If empty, the API uses it's default.

func SearchMultipleTypes added in v0.0.2

func SearchMultipleTypes(query string, searchTypes []string, sorting string, sortOrder string) (idgames []Idgame, err error)

func (Idgame) DownloadTo added in v0.0.3

func (g Idgame) DownloadTo(path string) (filePath string, err error)

DownloadTo tries to download the game to given path and returns the full path of the downloaded file

type IdgamesBrowser added in v0.0.5

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

IdgamesBrowser holds all fields of the module

func NewIdgamesBrowser added in v0.0.5

func NewIdgamesBrowser(app *tview.Application) *IdgamesBrowser

NewIdgamesBrowser is the modules constructor Must be initialized with a *tview.Application in which it is drawn

func (*IdgamesBrowser) FocusList added in v0.0.19

func (b *IdgamesBrowser) FocusList()

FocusList focuses the result list

func (*IdgamesBrowser) FocusSearch added in v0.0.19

func (b *IdgamesBrowser) FocusSearch()

FocusSearch focuses the search input field

func (*IdgamesBrowser) GetRootLayout added in v0.0.8

func (b *IdgamesBrowser) GetRootLayout() *tview.Pages

GetRootLayout returns the root layout

func (*IdgamesBrowser) GetSelectedRowNumber added in v0.0.18

func (b *IdgamesBrowser) GetSelectedRowNumber() int

GetRootLayout returns the root layout

func (*IdgamesBrowser) SetConfirmCallback added in v0.0.7

func (b *IdgamesBrowser) SetConfirmCallback(f func(idgame Idgame))

SetConfirmCallback sets a callback function that receives the Idgame instance of a row on which "ENTER" is pressed by the user This callbak function could, for example, launch a download of given file

func (*IdgamesBrowser) SetDownloadPath added in v0.0.7

func (b *IdgamesBrowser) SetDownloadPath(path string)

SetDownloadPath sets the path where the browser can download game files to

func (*IdgamesBrowser) SetPostDownloadCallback added in v0.0.16

func (b *IdgamesBrowser) SetPostDownloadCallback(doWhenDownloadDone func(archivePath string))

SetDownloadDoneCallback set a callback function which gets exectuted when the download has been finished the callback receives the local file path of the downloaded archive

func (*IdgamesBrowser) UpdateLatest added in v0.0.5

func (browser *IdgamesBrowser) UpdateLatest()

UpdateLatest triggers an API call for the latest entries and populates the UI with the results

func (*IdgamesBrowser) UpdateSearch added in v0.0.5

func (browser *IdgamesBrowser) UpdateSearch(query string, types []string)

UpdateSearch triggers an API call with given search query and types and populates the UI with the results

type Review

type Review struct {
	Text     string `json:"text"`     // The individual review's text, if any. Note: may be blank.
	Vote     int    `json:"vote"`     // The vote associated with the review.
	Username string `json:"username"` // The user name associated with the review, if any. Note: may be blank/null, which means "Anonymous". Since Version 3
}

Review represents a single review for one of the idgame files.

type WriteCounter added in v0.0.15

type WriteCounter struct {
	Total uint64
}

func (WriteCounter) PrintProgress added in v0.0.15

func (wc WriteCounter) PrintProgress()

func (*WriteCounter) Write added in v0.0.15

func (wc *WriteCounter) Write(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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