ds

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2016 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

Types

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(string) (*Game, error)
	// GetID takes the path of a ROM and returns the id to use in GetGame.
	GetID(string) (string, 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(id string) (*Game, error)

GetGame implements DS.

func (*Daphne) GetID added in v1.1.3

func (d *Daphne) GetID(p string) (string, error)

GetID implements DS.

func (*Daphne) GetName added in v1.1.3

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

GetName implements DS.

type GDB

type GDB struct {
	HM     *HashMap
	Hasher *Hasher
}

GDB is a DataSource using thegamesdb.net

func (*GDB) GetGame

func (g *GDB) GetGame(id string) (*Game, error)

GetGame implements DS

func (*GDB) GetID

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

GetID 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]string
	Thumbs      map[ImgType]string
	Rating      float64
	ReleaseDate string
	Developer   string
	Publisher   string
	Genre       string
	Players     int64
}

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 HashMap

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

HashMap a mapping of hash to names and GDB IDs.

func CachedHashMap

func CachedHashMap(p string) (*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) GetID

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

GetID returns the id for the given hash.

func (*HashMap) GetName

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

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

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 ImgType

type ImgType string

ImgType represents the different image types that sources may provide.

const (
	ImgBoxart  ImgType = "b"
	ImgScreen  ImgType = "s"
	ImgFanart  ImgType = "f"
	ImgBanner  ImgType = "a"
	ImgTitle   ImgType = "t"
	ImgMarquee ImgType = "m"
	ImgCabinet ImgType = "c"
)

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(p string) (*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(id string) (*Game, error)

GetGame implements DS.

func (*MAME) GetID

func (m *MAME) GetID(p string) (string, error)

GetID implements DS.

func (*MAME) GetName

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

GetName implements DS.

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(id string) (*Game, error)

GetGame implements DS.

func (*NeoGeo) GetID added in v1.1.4

func (n *NeoGeo) GetID(p string) (string, error)

GetID 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(h *Hasher) (*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(id string) (*Game, error)

GetGame implements DS.

func (*OVGDB) GetID

func (o *OVGDB) GetID(p string) (string, error)

GetID implements DS.

func (*OVGDB) GetName

func (o *OVGDB) 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(id string) (*Game, error)

GetGame implements DS.

func (*ScummVM) GetID

func (s *ScummVM) GetID(p string) (string, error)

GetID implements DS.

func (*ScummVM) GetName

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

GetName implements DS.

Jump to

Keyboard shortcuts

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