ds

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2015 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

NotFoundErr 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 {
	// GetGame 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 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)

func (*GDB) GetID

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

func (*GDB) GetName

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

func (*GDB) Hash added in v1.0.5

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

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.

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) (*Hasher, error)

NewHasher creates a new Hasher that hashes using the provided hash.

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
const (
	IMG_BOXART  ImgType = "b"
	IMG_SCREEN  ImgType = "s"
	IMG_FANART  ImgType = "f"
	IMG_BANNER  ImgType = "a"
	IMG_TITLE   ImgType = "t"
	IMG_MARQUEE ImgType = "m"
	IMG_CABINET 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

func (*MAME) GetGame

func (m *MAME) GetGame(id string) (*Game, error)

func (*MAME) GetID

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

func (*MAME) GetName

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

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 (db *OVGDB) Close() error

Close closes the DB.

func (*OVGDB) GetGame

func (o *OVGDB) GetGame(id string) (*Game, error)

func (*OVGDB) GetID

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

func (*OVGDB) GetName

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

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)

func (*ScummVM) GetID

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

func (*ScummVM) GetName

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

Jump to

Keyboard shortcuts

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