ds

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrImgNotFound = errors.New("image not found")

ErrImgNotFound is the error returned when a rom image can't be found.

View Source
var ErrNotFound = errors.New("hash not found")

ErrNotFound is the error returned when a rom can't be found in the source.

Functions

func DefaultCachePath

func DefaultCachePath() (string, error)

DefaultCachePath returns the path used for all cached data. Current <HOME>/.sselph-scraper or <HOMEDIR>\Application Data\sselph-scraper

func Draw added in v1.3.0

func Draw(ctx context.Context, def *Def, width, height int) (image.Image, error)

Draw draws the mix image.

Types

type ADB added in v1.2.6

type ADB struct {
	Limit chan struct{}
}

ADB is a Data Source using arcadeitalia and arcade-history.

func (*ADB) GetGame added in v1.2.6

func (a *ADB) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*ADB) GetName added in v1.2.6

func (a *ADB) GetName(p string) string

GetName implements DS.

type DS

type DS interface {
	// GetName takes the path of a ROM and returns the Pretty name if it differs from the Sources normal name.
	GetName(string) string
	// GetGame takes an id and returns the Game.
	GetGame(context.Context, string) (*Game, error)
}

DS is the interface all DataSoures should implement.

type Daphne added in v1.1.3

type Daphne struct {
	HM *HashMap
}

Daphne is a data source using GDB for Daphne games.

func (*Daphne) GetGame added in v1.1.3

func (d *Daphne) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*Daphne) GetName added in v1.1.3

func (d *Daphne) GetName(p string) string

GetName implements DS.

type Def added in v1.3.0

type Def struct {
	Width    int
	Height   int
	Elements []Element
}

Def represents the overall mix definition.

func StandardFour added in v1.3.0

func StandardFour(screen, box, cart, wheel Image) *Def

StandardFour creates a Def for the Standard 4 image mix.

func StandardThree added in v1.3.0

func StandardThree(screen, box, wheel Image) *Def

StandardThree creates a Def for the Standard 3 image mix.

type Element added in v1.3.0

type Element struct {
	Image    Image
	Width    Value
	Height   Value
	TopLeftX Value
	TopLeftY Value
	Fill     bool
}

Element represents an element in the overall image.

type GDB

type GDB struct {
	HM     *HashMap
	Hasher *Hasher
}

GDB is a DataSource using thegamesdb.net

func (*GDB) GetGame

func (g *GDB) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS

func (*GDB) GetName

func (g *GDB) GetName(p string) string

GetName implements DS

func (*GDB) Hash added in v1.0.5

func (g *GDB) Hash(p string) (string, error)

Hash hashes a ROM.

type Game

type Game struct {
	ID          string
	Source      string
	GameTitle   string
	Overview    string
	Images      map[ImgType]Image
	Thumbs      map[ImgType]Image
	Videos      map[VidType]Video
	Rating      float64
	ReleaseDate string
	Developer   string
	Publisher   string
	Genre       string
	Players     int64
	CloneOf     string
}

Game is the standard Game that all sources will return. They don't have to populate all values.

func NewGame

func NewGame() *Game

NewGame returns a new Game.

func ParseGDBGame added in v1.1.4

func ParseGDBGame(game gdb.Game, imgURL string) *Game

ParseGDBGame parses a gdb.Game and returns a Game.

type HTTPImage added in v1.2.1

type HTTPImage struct {
	URL   string
	Limit chan struct{}
}

func (HTTPImage) Get added in v1.2.1

func (i HTTPImage) Get(ctx context.Context, w, h uint) (image.Image, error)

func (HTTPImage) Save added in v1.2.1

func (i HTTPImage) Save(ctx context.Context, p string, w, h uint) error

type HTTPImageSS added in v1.2.1

type HTTPImageSS struct {
	URL   string
	Limit chan struct{}
}

func (HTTPImageSS) Get added in v1.2.1

func (i HTTPImageSS) Get(ctx context.Context, width, height uint) (image.Image, error)

func (HTTPImageSS) Save added in v1.2.1

func (i HTTPImageSS) Save(ctx context.Context, p string, width, height uint) error

type HTTPVideo added in v1.4.0

type HTTPVideo struct {
	URL   string
	E     string
	Limit chan struct{}
}

func (HTTPVideo) Ext added in v1.4.0

func (v HTTPVideo) Ext() string

func (HTTPVideo) Save added in v1.4.0

func (v HTTPVideo) Save(ctx context.Context, p string) error

type HTTPVideoSS added in v1.4.0

type HTTPVideoSS struct {
	URL   string
	E     string
	Limit chan struct{}
}

func (HTTPVideoSS) Ext added in v1.4.0

func (v HTTPVideoSS) Ext() string

func (HTTPVideoSS) Save added in v1.4.0

func (v HTTPVideoSS) Save(ctx context.Context, p string) error

type HashMap

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

HashMap a mapping of hash to names and GDB IDs.

func CachedHashMap

func CachedHashMap(ctx context.Context, p string, u bool) (*HashMap, error)

CachedHashMap gets the mapping of hashes to IDs.

func FileHashMap

func FileHashMap(p string) (*HashMap, error)

FileHashMap creates a hash map from a csv file.

func (*HashMap) ID added in v1.1.9

func (hm *HashMap) ID(s string) (string, bool)

GetID returns the id for the given hash.

func (*HashMap) Name added in v1.1.9

func (hm *HashMap) Name(s string) (string, bool)

GetName returns the no-intro name for the given hash.

func (*HashMap) System added in v1.1.9

func (hm *HashMap) System(s string) (int, bool)

type Hasher

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

Hasher is a thread-safe object to hash files. Hashes are cached and multiple calls to hash the same file wait for the first call to complete to read from cache.

func NewHasher

func NewHasher(hashFunc func() hash.Hash, threads int) (*Hasher, error)

NewHasher creates a new Hasher that hashes using the provided hash. threads is the expected number of threads a 4MB buffer will be created for each.

func (*Hasher) Hash

func (h *Hasher) Hash(p string) (string, error)

Hash returns the hash of the file at the given path.

type Image added in v1.2.1

type Image interface {
	Get(ctx context.Context, w, h uint) (image.Image, error)
	Save(ctx context.Context, p string, w, h uint) error
}

type ImgType

type ImgType string

ImgType represents the different image types that sources may provide.

const (
	ImgBoxart    ImgType = "b"
	ImgBoxart3D  ImgType = "3b"
	ImgScreen    ImgType = "s"
	ImgFanart    ImgType = "f"
	ImgBanner    ImgType = "a"
	ImgTitle     ImgType = "t"
	ImgMarquee   ImgType = "m"
	ImgCabinet   ImgType = "c"
	ImgFlyer     ImgType = "fly"
	ImgCart      ImgType = "cart"
	ImgCartLabel ImgType = "clabel"
	ImgMix3      ImgType = "mix3"
	ImgMix4      ImgType = "mix4"
)

Image types for Datasource options. Not all types are valid for all sources.

type MAME

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

MAME is a Data Source using mamedb and arcade-history.

func NewMAME

func NewMAME(ctx context.Context, p string, u bool) (*MAME, error)

NewMAME returns a new MAME. MAME should be closed when not needed.

func (*MAME) Close

func (m *MAME) Close() error

Close implements io.Closer.

func (*MAME) GetGame

func (m *MAME) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*MAME) GetName

func (m *MAME) GetName(p string) string

GetName implements DS.

type MixImage added in v1.3.0

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

func (MixImage) Get added in v1.3.0

func (i MixImage) Get(ctx context.Context, w, h uint) (image.Image, error)

func (MixImage) Save added in v1.3.0

func (i MixImage) Save(ctx context.Context, p string, w, h uint) error

type NeoGeo added in v1.1.4

type NeoGeo struct {
	HM *HashMap
}

NeoGeo is a data source using GDB for Daphne games.

func (*NeoGeo) GetGame added in v1.1.4

func (n *NeoGeo) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*NeoGeo) GetName added in v1.1.4

func (n *NeoGeo) GetName(p string) string

GetName implements DS.

type OVGDB

type OVGDB struct {
	Hasher *Hasher
	// contains filtered or unexported fields
}

OVGDB is a DataSource using OpenVGDB.

func NewOVGDB

func NewOVGDB(ctx context.Context, h *Hasher, u bool) (*OVGDB, error)

NewOVGDB returns a new OVGDB. OVGDB should be closed when not needed.

func (*OVGDB) Close

func (o *OVGDB) Close() error

Close closes the DB.

func (*OVGDB) GetGame

func (o *OVGDB) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*OVGDB) GetName

func (o *OVGDB) GetName(p string) string

GetName implements DS.

type PreDefValue added in v1.3.0

type PreDefValue int

PreDefValue are the predefined values for Values.

const (
	Undefined PreDefValue = iota
	Center
	Left
	Right
	Up
	Down
)

type SS added in v1.1.9

type SS struct {
	HM     *HashMap
	Hasher *Hasher
	Dev    ss.DevInfo
	User   ss.UserInfo
	Lang   []string
	Region []string
	Width  int
	Height int
	Limit  chan struct{}
}

SS is the source for ScreenScraper

func (*SS) GetGame added in v1.1.9

func (s *SS) GetGame(ctx context.Context, path string) (*Game, error)

GetGame implements DS

func (*SS) GetName added in v1.1.9

func (s *SS) GetName(p string) string

GetName implements DS

type SSMAME added in v1.2.0

type SSMAME struct {
	Dev    ss.DevInfo
	User   ss.UserInfo
	Lang   []string
	Region []string
	Width  int
	Height int
	Limit  chan struct{}
}

SSMAME is the source for ScreenScraper

func (*SSMAME) GetGame added in v1.2.0

func (s *SSMAME) GetGame(ctx context.Context, path string) (*Game, error)

GetGame implements DS

func (*SSMAME) GetName added in v1.2.0

func (s *SSMAME) GetName(p string) string

GetName implements DS

type ScummVM

type ScummVM struct {
	HM *HashMap
}

ScummVM is a data source using GDB for ScummVM games.

func (*ScummVM) GetGame

func (s *ScummVM) GetGame(ctx context.Context, p string) (*Game, error)

GetGame implements DS.

func (*ScummVM) GetName

func (s *ScummVM) GetName(p string) string

GetName implements DS.

type Value added in v1.3.0

type Value struct {
	Rel    float64
	Abs    int
	PreDef PreDefValue
}

Value is a value which can be absolute, relative, or a predefined short hand.

func (Value) V added in v1.3.0

func (v Value) V(total, img int) int

V returns the value based on the overall image dimension and the dimension of the overlayed image.

type VidType added in v1.4.0

type VidType string

VidTtpe represents the different video types that sources may provide.

const (
	VidStandard VidType = "v"
)

Video types for Datasource options. Not all types are valid for all sources.

type Video added in v1.4.0

type Video interface {
	Save(ctx context.Context, p string) error
	Ext() string
}

Jump to

Keyboard shortcuts

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