ds

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2017 License: MIT Imports: 26 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)
}

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(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 GDB

type GDB struct {
	HM     *HashMap
	Hasher *Hasher
}

GDB is a DataSource using thegamesdb.net

func (*GDB) GetGame

func (g *GDB) GetGame(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]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) 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 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"
)

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

type LangType added in v1.1.9

type LangType string

LangType represents the different language types that sources may provide.

const (
	LangEN LangType = "en"
	LangFR LangType = "fr"
	LangES LangType = "es"
	LangPT LangType = "pt"
	LangDE LangType = "de"
)

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

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

GetGame implements DS.

func (*OVGDB) GetName

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

GetName implements DS.

type RegionType added in v1.1.9

type RegionType string

RegionType represents the different region types that sources may provide.

const (
	RegionUnknown RegionType = ""
	RegionUS      RegionType = "us"
	RegionEU      RegionType = "eu"
	RegionFR      RegionType = "fr"
	RegionJP      RegionType = "jp"
	RegionXX      RegionType = "xx"
)

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

type SS added in v1.1.9

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

SS is the source for ScreenScraper

func (*SS) GetGame added in v1.1.9

func (s *SS) GetGame(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   []LangType
	Region []RegionType
	Width  int
	Height int
}

SSMAME is the source for ScreenScraper

func (*SSMAME) GetGame added in v1.2.0

func (s *SSMAME) GetGame(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(p string) (*Game, error)

GetGame 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