Documentation
¶
Overview ¶
Package importer brings watch history, collections and custom posters over from another media server's data folder, so switching to Matinee doesn't mean starting again. The media files stay where they are: what the other server knew about a file is matched to Matinee's item for the same file, by path, after the admin's path changes (the two servers may see the same share under different folders).
The format read here is the library database (SQLite) and metadata bundles that server keeps in its data folder.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoDatabase = errors.New("no media server data found there")
ErrNoDatabase means a folder has no library database in it, nor in the folders a few levels down.
var ErrUnreadable = fmt.Errorf("that isn't a media server database Matinee can read")
ErrUnreadable means the file isn't a library database Matinee can read.
Functions ¶
func Find ¶
func Find() []string
Find lists data folders found where that server keeps them by default on this computer, for an admin to pick from.
func MapPath ¶
func MapPath(p string, changes []PathChange) string
MapPath applies the change with the longest matching start, and writes the rest of the path with the separators Matinee's side uses.
Types ¶
type AccountSummary ¶
type AccountSummary struct {
Account
Watched int `json:"watched"`
InProgress int `json:"inProgress"`
Rated int `json:"rated"`
Found int `json:"found"` // of those watched, on Matinee
}
AccountSummary is how much one account watched there, and how much of it Matinee has.
type Collection ¶
Collection is a named group of items.
type Item ¶
type Item struct {
ID int64
ParentID int64
Type int
GUID string
Hash string // names its metadata bundle
Poster string // the poster it uses; "upload://posters/…" for one someone uploaded
Title string
}
Item is a movie, show, season, episode, artist, album or track there.
type Location ¶
type Location struct {
DB string // the library database
// DataDir is the data folder holding Metadata/ (custom posters); empty
// when only the database is at hand, such as one uploaded on its own.
DataDir string
}
Location is where an import reads from.
type Options ¶
type Options struct {
// Accounts maps the other server's accounts to Matinee's accounts or
// profiles; accounts left out are skipped.
Accounts map[int64]int64
Watched bool
Collections bool
Posters bool
Ratings bool
// Step is told what's done so far, out of the total, as the import goes.
Step func(done, total int)
}
Options say what an import brings over, and for whom.
type PathChange ¶
type PathChange struct {
From string `json:"from"`
To string `json:"to"`
// Files is how many files the change finds, when it's a suggestion.
Files int `json:"files,omitempty"`
}
PathChange turns the start of the other server's paths into Matinee's: the same share may be /data/movies to one and /mnt/media/movies to the other.
func SuggestChanges ¶
func SuggestChanges(files []string, known func(string) bool, byName map[string][]string, have []PathChange) []PathChange
SuggestChanges looks at the files that don't match and finds the path changes that would match them: a Matinee file with the same name and the same folders above it, up to where the two paths differ. It returns the changes that each find at least two files (or one, when that's all there is), most files first.
type Plan ¶
type Plan struct {
Changes []PathChange
// Files counts the other server's files, and Matched the ones Matinee has.
Files, Matched int
// Unmatched lists a few files Matinee doesn't have, as examples.
Unmatched []string
// Suggested are path changes that would match more files.
Suggested []PathChange
// contains filtered or unexported fields
}
Plan is a snapshot matched to Matinee's files with a set of path changes.
func NewPlan ¶
func NewPlan(snap *Snapshot, files []store.FileRef, changes []PathChange) *Plan
NewPlan matches a snapshot's files to Matinee's.
func (*Plan) Accounts ¶
func (p *Plan) Accounts() []AccountSummary
Accounts sums up each account's history.
func (*Plan) Apply ¶
Apply brings the history, collections and posters over. Places and watched marks only replace Matinee's own when the other server's are newer, so running an import again, or after watching here, loses nothing.
func (*Plan) Collections ¶
Collections counts the collections with something Matinee has.
type Result ¶
type Result struct {
Watched int `json:"watched"` // marked watched
InProgress int `json:"inProgress"` // given a place to resume from
Kept int `json:"kept"` // left alone: watched more recently on Matinee
Collections int `json:"collections"` // made or added to
CollectionItems int `json:"collectionItems"` // titles put in them
Posters int `json:"posters"`
Ratings int `json:"ratings"` // given or changed
}
Result says what an import did.
type Snapshot ¶
type Snapshot struct {
Location Location
Accounts []Account
Items map[int64]*Item
Files map[int64][]string // item id → its files, in part order
Views []View
Collections []Collection
}
Snapshot is everything an import uses, read in one go.
type View ¶
type View struct {
AccountID int64
GUID string
OffsetMs int64
Count int64
LastViewed int64 // Unix seconds; 0 when unknown
// Rating is the account's rating out of 10 (0 for none), and RatedAt
// when it was given.
Rating float64
RatedAt int64
}
View is where one account is in one item, keyed by the item's GUID.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package importertest builds a small data folder in the other media server's format, for tests.
|
Package importertest builds a small data folder in the other media server's format, for tests. |