func GetMAMEGame(r *ROM) (*GameXML, error) { g, err := mamedb.GetGame(r.bName, strings.Split(*mameImg, ",")) if err != nil { return nil, err } iPath, _ := GetImgPaths(r) if g.Art != "" && *downloadImages { err = getImage(g.Art, iPath) if err != nil { return nil, err } } else { iPath = "" } gxml := &GameXML{ Path: fixPath(*romPath + "/" + strings.TrimPrefix(r.Path, *romDir)), ID: g.ID, GameTitle: g.Name, ReleaseDate: g.Date, Developer: g.Developer, Genre: g.Genre, Source: g.Source, Players: g.Players, Rating: g.Rating / 10.0, } if iPath != "" { gxml.Image = fixPath(*imagePath + "/" + strings.TrimPrefix(iPath, *imageDir)) } return gxml, nil }
func (m *MAME) GetGame(id string) (*Game, error) { g, err := mamedb.GetGame(id) if err != nil { if err == mamedb.NotFound { return nil, NotFoundErr } return nil, err } game := NewGame() game.ID = g.ID game.GameTitle = g.Name game.ReleaseDate = g.Date game.Developer = g.Developer game.Genre = g.Genre game.Source = g.Source game.Players = g.Players game.Rating = g.Rating / 10.0 if g.Title != "" { game.Images[IMG_TITLE] = g.Title game.Thumbs[IMG_TITLE] = g.Title } if g.Snap != "" { game.Images[IMG_SCREEN] = g.Snap game.Thumbs[IMG_SCREEN] = g.Snap } if g.Marquee != "" { game.Images[IMG_MARQUEE] = g.Marquee game.Thumbs[IMG_MARQUEE] = g.Marquee } if g.Cabinet != "" { game.Images[IMG_CABINET] = g.Cabinet game.Thumbs[IMG_CABINET] = g.Cabinet } hi, err := m.db.Get([]byte(id), nil) if err == nil { desc, err := m.db.Get(hi, nil) if err == nil { game.Overview = string(desc) } } return game, nil }