library

package module
v0.0.0-...-efa5fdd Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: BSD-2-Clause Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDbNotOpened = fmt.Errorf("database not opened")
View Source
var ErrDbPathNotSet = fmt.Errorf("database path not set")
View Source
var ErrInvalidMediaType = fmt.Errorf("invalid media type")
View Source
var ErrInvalidName = fmt.Errorf("invalid name")
View Source
var ErrInvalidProperty = fmt.Errorf("invalid property")
View Source
var ErrInvalidStreamIndex = fmt.Errorf("invalid stream index")
View Source
var ErrInvalidType = fmt.Errorf("invalid type")
View Source
var ErrMediaPathNotDir = fmt.Errorf("media path not a valid directory")
View Source
var ErrMediaPathNotSet = fmt.Errorf("media path not set")
View Source
var ErrMissingAudioStream = fmt.Errorf("missing audio stream")
View Source
var ErrMissingVideoStream = fmt.Errorf("missing video stream")
View Source
var ErrNotFound = fmt.Errorf("not found")
View Source
var ErrPathExists = fmt.Errorf("path already exists")
View Source
var ErrQueryFailed = fmt.Errorf("database query failed")
View Source
var InvalidDiskCharacters *regexp.Regexp = regexp.MustCompile(`[<>:"/\\|?*$!%\'` + "`" + `~]`)

characters not allowed in Category.Name, or Metadata.NameSort fields (characters disallowed by exfat, plus some extras)

View Source
var Migrations []Migration = []Migration{
	&migration0000{},
	&migration0001{},
	&migration0002{},
}

Functions

func CategoryDelete

func CategoryDelete(cat *Category) error

func CategoryIdExists

func CategoryIdExists(id string) bool

func CategoryIsEmpty

func CategoryIsEmpty(id string) bool

func CategoryNameExists

func CategoryNameExists(name string) bool

func CategoryReindex

func CategoryReindex(cat *Category, index int64) error

func CategoryUpdate

func CategoryUpdate(cat *Category, name string, media_type string) error

func InputFileCreate

func InputFileCreate(inp *InputFile) error

func InputFileDelete

func InputFileDelete(inp *InputFile) error

func InputFileExistsForSource

func InputFileExistsForSource(source_location string) bool

func JwtKeyGet

func JwtKeyGet() ([]byte, error)

Get JWT key.

func LibraryReady

func LibraryReady() error

func LibraryShutdown

func LibraryShutdown()

func LibraryStartup

func LibraryStartup(database_path string) error

func MediaPathGet

func MediaPathGet() (string, error)

func MediaPathSet

func MediaPathSet(new_path string) error

Set the media path. This involves moving the media directory, and may take a while. This call should not be allowed from a web interface.

func MediaPathValid

func MediaPathValid() bool

func MetadataCreate

func MetadataCreate(md *Metadata) error

func MetadataDelete

func MetadataDelete(md *Metadata, delete_children bool) error

func MetadataIdExists

func MetadataIdExists(id string) bool

func MetadataIsEmpty

func MetadataIsEmpty(id string) bool

func MigrateTo

func MigrateTo(level_target uint32) (err error)

Migrate to specified level. NOTE: Creates a backup of db before starting, and rolls back if migration fails. NOTE: This will overwrite the current backup file.

func MigrateToLatest

func MigrateToLatest() (err error)

Migrate to the latest level.

func MigrationLevelGet

func MigrationLevelGet() (level uint32)

Get current migration level.

func PropertyDelete

func PropertyDelete(key string) error

func PropertyGet

func PropertyGet(key string) (string, error)

func PropertyList

func PropertyList() (map[string]string, error)

List all properties that can be freely edited.

func PropertySet

func PropertySet(key string, value string) error

Types

type Category

type Category struct {
	Id        string            `json:"id"`
	MediaType CategoryMediaType `json:"media_type"`
	Name      string            `json:"name"`
	SortIndex int64             `json:"sort_index"`
}

func CategoryCreate

func CategoryCreate(name string, media_type CategoryMediaType) (*Category, error)

func CategoryList

func CategoryList() ([]Category, error)

func CategoryRead

func CategoryRead(id string) (*Category, error)

func (*Category) Copy

func (cat *Category) Copy() *Category

func (*Category) DiskPath

func (cat *Category) DiskPath() string

func (*Category) FieldsDifference

func (cat_a *Category) FieldsDifference(other dbRecord) (diff map[string]any, err error)

func (*Category) FieldsPatch

func (cat *Category) FieldsPatch(fields map[string]any) (err error)

func (*Category) FieldsRead

func (cat *Category) FieldsRead() (fields map[string]any, err error)

func (*Category) FieldsReplace

func (cat *Category) FieldsReplace(fields map[string]any) (err error)

func (*Category) GetId

func (cat *Category) GetId() string

func (*Category) RecordCopy

func (cat *Category) RecordCopy() (dbRecord, error)

func (*Category) RecordCreate

func (cat *Category) RecordCreate(fields map[string]any) (instance dbRecord, err error)

func (*Category) SetId

func (cat *Category) SetId(id string)

func (*Category) TableName

func (cat *Category) TableName() string

type CategoryMediaType

type CategoryMediaType string
const (
	CategoryMediaTypeMovie  CategoryMediaType = "movie"
	CategoryMediaTypeSeries CategoryMediaType = "series"
	CategoryMediaTypeMusic  CategoryMediaType = "music"
)

type FileStream

type FileStream struct {
	StreamType FileStreamType `json:"stream_type"`
	Index      int64          `json:"index"`
	Codec      string         `json:"codec"`
	Width      int64          `json:"width"`
	Height     int64          `json:"height"`
	Fps        int64          `json:"fps"`
	Channels   int64          `json:"channels"`
	Language   string         `json:"language"`
}

func FileStreamsList

func FileStreamsList(path string) (file_streams []FileStream, duration int64, err error)

func (*FileStream) Copy

func (stream *FileStream) Copy() *FileStream

type FileStreamType

type FileStreamType string
const (
	FileStreamTypeVideo    FileStreamType = "video"
	FileStreamTypeAudio    FileStreamType = "audio"
	FileStreamTypeSubtitle FileStreamType = "subtitle"
)

type InputFile

type InputFile struct {
	Id                     string       `json:"id"`              // Metadata.Id == InputFile.Id
	SourceLocation         string       `json:"source_location"` // path to source file
	SourceStreams          []FileStream `json:"source_streams"`
	StreamMap              []int64      `json:"stream_map"`      // empty == needs_map
	SourceDuration         int64        `json:"source_duration"` // length of media in seconds
	TimeScanned            int64        `json:"time_scanned"`
	TranscodingCommand     string       `json:"transcoding_command"`      // ffmpeg command line
	TranscodingTimeStarted int64        `json:"transcoding_time_started"` // time transcoding was started
	TranscodingTimeElapsed int64        `json:"transcoding_time_elapsed"` // seconds elapsed during transcoding
	TranscodingError       string       `json:"transcoding_error"`        // error message from transcoding process
}

func InputFileList

func InputFileList() ([]InputFile, error)

func InputFileNextForTranscoding

func InputFileNextForTranscoding() (*InputFile, error)

func InputFileRead

func InputFileRead(id string) (*InputFile, error)

func (*InputFile) Copy

func (inp *InputFile) Copy() *InputFile

func (*InputFile) FieldsDifference

func (inp_a *InputFile) FieldsDifference(other dbRecord) (diff map[string]any, err error)

func (*InputFile) FieldsPatch

func (inp *InputFile) FieldsPatch(fields map[string]any) (err error)

func (*InputFile) FieldsRead

func (inp *InputFile) FieldsRead() (fields map[string]any, err error)

func (*InputFile) FieldsReplace

func (inp *InputFile) FieldsReplace(fields map[string]any) (err error)

func (*InputFile) GetId

func (inp *InputFile) GetId() string

func (*InputFile) OutputNames

func (inp *InputFile) OutputNames() (name_display string, name_sort string, path string)

func (*InputFile) OutputType

func (inp *InputFile) OutputType() FileStreamType

func (*InputFile) RecordCopy

func (inp *InputFile) RecordCopy() (dbRecord, error)

func (*InputFile) RecordCreate

func (inp *InputFile) RecordCreate(fields map[string]any) (instance dbRecord, err error)

func (*InputFile) Remap

func (inp *InputFile) Remap(source_stream_map []int64) error

func (*InputFile) SetId

func (inp *InputFile) SetId(id string)

func (*InputFile) StatusDidSucceed

func (inp *InputFile) StatusDidSucceed() bool

func (*InputFile) StatusReset

func (inp *InputFile) StatusReset() error

func (*InputFile) StatusSetFailed

func (inp *InputFile) StatusSetFailed(time int64, error string) error

func (*InputFile) StatusSetStarted

func (inp *InputFile) StatusSetStarted(time int64, command string) error

func (*InputFile) StatusSetSucceeded

func (inp *InputFile) StatusSetSucceeded(time int64) error

func (*InputFile) TableName

func (inp *InputFile) TableName() string

type Metadata

type Metadata struct {
	Id          string            `json:"id"`
	ParentId    string            `json:"parent_id"`
	MediaType   MetadataMediaType `json:"media_type"`
	NameDisplay string            `json:"name_display"`
	NameSort    string            `json:"name_sort"`
	Streams     []FileStream      `json:"streams"`
	Duration    int64             `json:"duration"`
	Size        int64             `json:"size"`
}

func MetadataForParent

func MetadataForParent(parent_id string) ([]Metadata, error)

func MetadataRead

func MetadataRead(id string) (*Metadata, error)

func (*Metadata) Copy

func (md *Metadata) Copy() *Metadata

func (*Metadata) DiskPath

func (md *Metadata) DiskPath(path_type MetadataPathType) (string, error)

func (*Metadata) FieldsDifference

func (md_a *Metadata) FieldsDifference(other dbRecord) (diff map[string]any, err error)

func (*Metadata) FieldsPatch

func (md *Metadata) FieldsPatch(fields map[string]any) (err error)

func (*Metadata) FieldsRead

func (md *Metadata) FieldsRead() (fields map[string]any, err error)

func (*Metadata) FieldsReplace

func (md *Metadata) FieldsReplace(fields map[string]any) (err error)

func (*Metadata) GetId

func (md *Metadata) GetId() string

func (*Metadata) RecordCopy

func (md *Metadata) RecordCopy() (dbRecord, error)

func (*Metadata) RecordCreate

func (md *Metadata) RecordCreate(fields map[string]any) (instance dbRecord, err error)

func (*Metadata) Rename

func (md *Metadata) Rename(new_name_display string, new_name_sort string) error

func (*Metadata) Reparent

func (md *Metadata) Reparent(new_parent_id string) error

func (*Metadata) SetId

func (md *Metadata) SetId(id string)

func (*Metadata) SetPoster

func (md *Metadata) SetPoster(img image.Image) error

func (*Metadata) TableName

func (md *Metadata) TableName() string

type MetadataMediaType

type MetadataMediaType string
const (
	MetadataMediaTypeFileVideo MetadataMediaType = "file-video"
	MetadataMediaTypeFileAudio MetadataMediaType = "file-audio"
	MetadataMediaTypeSeries    MetadataMediaType = "series"
	MetadataMediaTypeSeason    MetadataMediaType = "season"
	MetadataMediaTypeArtist    MetadataMediaType = "artist"
	MetadataMediaTypeAlbum     MetadataMediaType = "album"
)

type MetadataPathType

type MetadataPathType string
const (
	MetadataPathTypeBase        MetadataPathType = "base"
	MetadataPathTypeMedia       MetadataPathType = "media"
	MetadataPathTypePosterLarge MetadataPathType = "poster_large"
	MetadataPathTypePosterSmall MetadataPathType = "poster_small"
)

type MetadataTreeNode

type MetadataTreeNode struct {
	Id        string             `json:"id"`
	Name      string             `json:"name"`
	MediaType string             `json:"media_type"`
	Children  []MetadataTreeNode `json:"children"` // not a map because want this ordered
}

func MetadataParentTree

func MetadataParentTree(parent_id string) ([]MetadataTreeNode, error)

type Migration

type Migration interface {
	Up() error
	Down() error
}

Jump to

Keyboard shortcuts

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