migrate

package
v0.2.58 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package migrate performs read-only PMS discovery and reviewed, idempotent local imports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	External  string         `json:"external"`
	Key       core.RatingKey `json:"key"`
	Title     string         `json:"title"`
	Viewer    int64          `json:"viewer"`
	Views     int            `json:"views"`
	Offset    int64          `json:"offsetMs"`
	Duration  int64          `json:"durationMs"`
	Rating    float64        `json:"rating"`
	ViewedAt  int64          `json:"viewedAt"`
	Watchlist bool           `json:"watchlist,omitempty"`
}

type List

type List struct {
	External string           `json:"external"`
	Name     string           `json:"name"`
	Kind     string           `json:"kind"`
	Viewer   int64            `json:"viewer"`
	Keys     []core.RatingKey `json:"keys"`
}

type Options

type Options struct {
	State *state.State
	Users interface {
		User(context.Context, int64) (*core.User, error)
	}
	Logger *slog.Logger
}

type Plan

type Plan struct {
	ID       string   `json:"id"`
	Source   string   `json:"source"`
	Items    []Item   `json:"items"`
	History  []Item   `json:"history"`
	Lists    []List   `json:"lists"`
	Viewers  []Viewer `json:"viewers"`
	Warnings []string `json:"warnings"`
	Imported bool     `json:"imported"`
}

type PreviewProgress added in v0.2.49

type PreviewProgress struct {
	Phase     string `json:"phase"`
	Pages     int    `json:"pages"`
	Scanned   int    `json:"scanned"`
	Matched   int    `json:"matched"`
	Unmatched int    `json:"unmatched"`
}

PreviewProgress is the counts a running preview exposes while it scans.

type PreviewStatus added in v0.2.49

type PreviewStatus struct {
	ID       string          `json:"id"`
	Status   string          `json:"status"`
	Progress PreviewProgress `json:"progress"`
	Error    string          `json:"error,omitempty"`
	Plan     *Plan           `json:"plan,omitempty"`
}

PreviewStatus is the owner-facing preview job. Plan is set only when Status is done.

type Request

type Request struct {
	URL         string   `json:"url"`
	Token       string   `json:"token"`
	Viewers     []Viewer `json:"viewers"`
	HistoryOnly bool     `json:"historyOnly,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, catalog core.Catalog, opts ...Options) *Service

func (*Service) CancelPreview added in v0.2.49

func (s *Service) CancelPreview(id string) (PreviewStatus, bool)

func (*Service) ExportCSV

func (s *Service) ExportCSV(ctx context.Context, viewer int64, format, kind string, w io.Writer) error

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler is intentionally unauthenticated: mount inside the owner's authenticated router.

func (*Service) Import

func (s *Service) Import(ctx context.Context, id string) (Plan, error)

func (*Service) Preview

func (s *Service) Preview(ctx context.Context, q Request) (Plan, error)

func (*Service) PreviewCSV

func (s *Service) PreviewCSV(ctx context.Context, viewer int64, format, kind string, r io.Reader) (Plan, error)

PreviewCSV accepts Letterboxd diary/ratings/watchlist and Trakt CSV columns. Letterboxd's export lacks external IDs, so exact title AND year are required.

func (*Service) PreviewStatus added in v0.2.49

func (s *Service) PreviewStatus(id string) (PreviewStatus, bool)

func (*Service) StartPreview added in v0.2.49

func (s *Service) StartPreview(q Request) (PreviewStatus, error)

StartPreview validates the request, then scans PMS on a background context. The POST that starts it returns as soon as the job exists.

type Viewer

type Viewer struct {
	LocalUserID     int64  `json:"localUserId"`
	PlexID          int64  `json:"plexId"`
	Name            string `json:"name"`
	Token           string `json:"token,omitempty"`
	SourceAccountID int64  `json:"sourceAccountId,omitempty"`
}

Jump to

Keyboard shortcuts

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