progress

package
v0.0.0-...-5edc56a Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package progress manages user progress data which contains media offset and duration to allow incremental watch/listen progress to be saved and retrieved to/from the server based on etag.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOffsetTooOld = errors.New("offset is old")
	ErrOffsetSame   = errors.New("offset is the same")
	ErrAccessDenied = errors.New("access denied")
)

Functions

This section is empty.

Types

type Offset

type Offset struct {
	gorm.Model
	User     string    `gorm:"index:idx_offset_user" json:"-"`
	ETag     string    `gorm:"uniqueIndex:idx_offset_etag;uniqueIndex:idx_offset_date"`
	Offset   int       `gorm:"default:0"`
	Duration int       `gorm:"default:0"`
	Date     time.Time `gorm:"uniqueIndex:idx_offset_date"`
}

func (Offset) Valid

func (o Offset) Valid() bool

type Offsets

type Offsets struct {
	Offsets []Offset
}

type Progress

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

func NewProgress

func NewProgress(config *config.Config) *Progress

func (*Progress) Close

func (p *Progress) Close()

func (*Progress) Delete

func (p *Progress) Delete(user *auth.User, offset Offset) error

Delete will delete the provided user & offset, ensuring the offset belongs to the user.

func (*Progress) Offset

func (p *Progress) Offset(user *auth.User, id int) *Offset

Offset gets the user offset based on the internal id.

func (*Progress) Offsets

func (p *Progress) Offsets(user *auth.User) []Offset

Offsets gets all the offets for the user.

func (*Progress) Open

func (p *Progress) Open() (err error)

func (*Progress) Update

func (p *Progress) Update(user *auth.User, newOffset Offset) error

Update will create or update an offset for the provided user using the etag as the primary key.

Jump to

Keyboard shortcuts

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