media

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package media manages video library functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortByTimestamp

func SortByTimestamp(v1, v2 *Video) bool

SortByTimestamp sorts the playlist by Timestamp

func SortByViews

func SortByViews(v1, v2 *Video) bool

SortByViews sorts the playlist by Views

Types

type By

type By func(v1, v2 *Video) bool

By is the type of a "less" function that defines the ordering of its Playlist arguments.

func (By) Sort

func (by By) Sort(pl Playlist)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type Library

type Library struct {
	Paths  map[string]*Path
	Videos map[string]*Video
	// contains filtered or unexported fields
}

Library manages importing and retrieving video data.

func NewLibrary

func NewLibrary() *Library

NewLibrary returns new instance of Library.

func (*Library) Add

func (lib *Library) Add(fp string) error

Add adds a single video from a given file path.

func (*Library) AddPath

func (lib *Library) AddPath(p *Path) error

AddPath adds a media path to the library.

func (*Library) Import

func (lib *Library) Import(p *Path) error

Import adds all valid videos from a given path.

func (*Library) Playlist

func (lib *Library) Playlist() Playlist

Playlist returns a sorted Playlist of all videos.

func (*Library) Remove

func (lib *Library) Remove(fp string)

Remove removes a single video from a given file path.

type Path

type Path struct {
	Path   string
	Prefix string
}

Path represents a media library path.

type Playlist

type Playlist []*Video

type Video

type Video struct {
	ID          string
	Title       string
	Album       string
	Description string
	Thumb       []byte
	ThumbType   string
	Modified    string
	Size        int64
	Path        string
	Timestamp   time.Time

	Views int64
}

Video represents metadata for a single video.

func ParseVideo

func ParseVideo(p *Path, name string) (*Video, error)

ParseVideo parses a video file's metadata and returns a Video.

Jump to

Keyboard shortcuts

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