Documentation
¶
Overview ¶
Package gamescan is what a scan of a games library finds (module API 5, scan.identify): the server walks the library's folders and sends WittyPlay every file; this decides which are games, for which console, and which files are one game (a sheet and its tracks, the discs of a set, copies of one file, versions of one game). See docs/GAMING.md in the server.
ROM files are only listed here, never opened beyond a look at their headers and at which files an archive, .cue or .m3u names. Archives are only read in a worker process.
Index ¶
- Constants
- Variables
- func CleanName(base string) (title, tags string)
- func Decide(ctx context.Context, db *sql.DB, library int64, p, action, console string) error
- func DecideReviewed(ctx context.Context, db *sql.DB, library, reviewID int64, ...) (string, error)
- func Entry(ctx context.Context, db *sql.DB, library int64, p string) string
- func ForgetLibrary(ctx context.Context, db *sql.DB, library int64) error
- func ItemAt(ctx context.Context, db *sql.DB, library int64, p string) int64
- func NameKey(name string) string
- func NoteItem(ctx context.Context, db *sql.DB, library int64, p string, item int64) error
- func ParseGameName(base string) (title, note string)
- func PinEntry(ctx context.Context, db *sql.DB, library int64, p, entry string) error
- func ProblemText(problem, proof string) string
- func RegionsChanged(ctx context.Context, db *sql.DB, library int64) error
- func RereadAll(ctx context.Context, db *sql.DB, library int64) error
- func ReviewCounts(ctx context.Context, db *sql.DB, library int64) (map[string]int, error)
- func SearchTitle(title string) string
- func Serial(ctx context.Context, db *sql.DB, library int64, p string) string
- func SetSerial(ctx context.Context, db *sql.DB, library int64, p, serial string) error
- func SortTitle(t string) string
- type Detected
- type GameDisc
- type GameReview
- type GameReviewItem
- type GameSuggestion
- type Listed
- type Scan
- func (s *Scan) Add(ctx context.Context, files []wittymodule.ScanFile, total int) error
- func (s *Scan) Close()
- func (s *Scan) Finish(ctx context.Context, offline []string) (wittymodule.ScanIdentified, error)
- func (s *Scan) LastHeard() time.Time
- func (s *Scan) Progress() (done, total int, current string)
Constants ¶
const DecryptedCopyPlays = "A copy you decrypted yourself, from a console you own, will play."
DecryptedCopyPlays is what a person with an encrypted game can do: nothing here decrypts one, or looks for keys, but a copy they decrypted themselves plays like any other game.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound: no such line on the review list, or no such game.
Functions ¶
func CleanName ¶
CleanName splits a file's base name into the game's title and what else the name says, e.g. "Mega Game, The (USA) (Rev 1)" -> "The Mega Game", "USA, Rev 1".
func Decide ¶
Decide records what a person said about a file, and the next scan goes by it. action is add (with a console), ignore, own (never put it under another version), or forget, which takes back whatever was said.
func DecideReviewed ¶
func DecideReviewed(ctx context.Context, db *sql.DB, library, reviewID int64, action, console string) (string, error)
DecideReviewed records what a person said about a file on the review list, by its line. It returns the file's path.
func ForgetLibrary ¶
ForgetLibrary drops everything kept about a library's files, once it's gone.
func NoteItem ¶
NoteItem remembers the server's id for a game's path, as the server says it (an item it sent).
func ParseGameName ¶
ParseGameName splits a game's file name into its title and a short note made of its tags, e.g. "Mega Game, The (USA) (Rev 1)" -> "The Mega Game", "USA, Rev 1".
func ProblemText ¶
ProblemText says why a game can't play as it is, from what the scan found ("encrypted").
func RegionsChanged ¶
RegionsChanged makes the owner's new order of regions count at a library's next scan: an archive's file is worked out again, unless someone chose it, and so is which version leads a game.
func RereadAll ¶
RereadAll makes a library's next scan work out every file again from the start, as a full rescan asks: what's kept about each file is set aside (as an older version's would be) and replaced as each is judged again, so a full rescan that's stopped carries on from where it got to. What people said about files stays.
func ReviewCounts ¶
ReviewCounts says how many files of each kind a library's review list has.
func SearchTitle ¶
SearchTitle takes off what no database calls a game: which disc this is, and a product code left in the name. "Dashes-for-spaces" names become words.
Types ¶
type Detected ¶
type Detected struct {
How, Proof, Problem, ProblemText string
Sure int
Title, Serial, Name, Entry string // what the file calls itself; the archive entry played
}
Detected is how a game's file was identified, as its metadata pages show it.
type GameReview ¶
type GameReview struct {
Items []GameReviewItem `json:"items"`
Counts map[string]int `json:"counts"`
Total int `json:"total"`
}
GameReview is the review list, with how many of each kind there are.
type GameReviewItem ¶
type GameReviewItem struct {
ID int64 `json:"id"`
// Path is relative to the library's folder, Name the file's own name.
Path string `json:"path"`
Name string `json:"name"`
Size int64 `json:"size"`
// Kind is needs (a person should look), blocked (it's listed, and can't play as it is),
// or what it was left out as: bios, update, dlc, utility, audio, data, other, duplicate,
// or ignored.
Kind string `json:"kind"`
Reason string `json:"reason"`
// Suggest lists consoles it might be, best first, each with a name to show.
Suggest []GameSuggestion `json:"suggest"`
// ItemID is the game this file is listed as, when it is.
ItemID int64 `json:"itemId,omitempty"`
}
GameReviewItem is one line of the review list.
type GameSuggestion ¶
type GameSuggestion struct {
Console string `json:"console"`
Name string `json:"name"`
Short string `json:"short"`
}
GameSuggestion is a console a file might be for.
type Listed ¶
type Listed struct {
Library int64
Path string
VersionOf string // the path of the game it's another version of, or ""
Label string // which version it is, when it's under another
Tagline string // what the scan made of its name: region, revision
Discs []GameDisc // only for a game on several discs
Item int64 // the server's id for it, once known
}
Listed is a game as the last scan answered it.
func ListedGame ¶
ListedGame is the game the last scan of a library answered at this path.
func ListedItem ¶
ListedItem is the game the last scan answered that the server knows by this id.
type Scan ¶
type Scan struct {
ID string
Library wittymodule.ScanLibrary
Started time.Time
// Report, when set, is told how far the scan has got whenever that moves: the files of
// a batch judged, of the scan's total, and then Finish's work, also counted in files. It's
// called often, from the call's goroutine, and has to be quick (it's for the server's
// progress and its watch for a stuck scan: see api/scan_progress.go).
Report func(done, total int)
// contains filtered or unexported fields
}
Scan is one scan of one library, from its first batch of files to its last call (Done).
func Begin ¶
func Begin(db *sql.DB, id string, lib wittymodule.ScanLibrary) *Scan
Begin starts a scan of a library. db may be nil: nothing is remembered past the scan.
func (*Scan) Add ¶
Add takes in a batch of files, in the order the walk found them. total is how many the walk found in all, when it says.
func (*Scan) Close ¶
func (s *Scan) Close()
Close lets go of what the scan holds open (its archive reader).
func (*Scan) Finish ¶
func (s *Scan) Finish(ctx context.Context, offline []string) (wittymodule.ScanIdentified, error)
Finish works out every game the library holds now, keeps what the scan learned, and answers the server. offline are folders that couldn't be read this time: what's known about their files stays.