client

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Dev = iota
	Prod
)
View Source
const (
	Downloading = iota
	DownloadDone
	Failed
)
View Source
const (
	MasterPlaylistName = "master.m3u8"
)

Variables

View Source
var (
	TranscodedCacheSizeBytes = promauto.NewGauge(prometheus.GaugeOpts{
		Name: "transcoded_cache_size_bytes",
	})
	TranscodedCacheItemsCount = promauto.NewGauge(prometheus.GaugeOpts{
		Name: "transcoded_cache_items_count",
	})
	TranscodedResult = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "transcoded_request_result",
	}, []string{"type"})
)
View Source
var ErrAlreadyDownloading = errors.New("video is already downloading")

ErrAlreadyDownloading when returned means that video retrieval is already underway and nothing needs to be done at this time.

Functions

func HLSPlaylistDive added in v0.5.0

func HLSPlaylistDive(rootPath string, loader fileLoader, processor fileProcessor) (int64, error)

HLSPlaylistDive processes HLS streams, calling `load` to load and `process` for each master/child playlists and all the files they reference.

func PoolDownload added in v0.6.0

func PoolDownload(d Downloadable) *dispatcher.Result

Types

type CachedVideo

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

func (*CachedVideo) DirName

func (v *CachedVideo) DirName() string

func (*CachedVideo) Size

func (v *CachedVideo) Size() int64

type Client

type Client struct {
	*Configuration
	// contains filtered or unexported fields
}

func New

func New(cfg *Configuration) Client

func (Client) CacheVideo

func (c Client) CacheVideo(path string, size int64)

func (Client) Get

func (c Client) Get(kind, lbryURL, sdHash string) (*CachedVideo, Downloadable)

Get returns either a cached video or downloadable instance for further processing.

func (Client) GetCachedVideo

func (c Client) GetCachedVideo(sdHash string) *CachedVideo

func (Client) SweepCache added in v0.5.2

func (c Client) SweepCache(restore bool) (int64, error)

SweepCache goes through cache directory and removes broken streams, optionally restoring healthy ones in the cache.

type Configuration

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

func Configure

func Configure() *Configuration

func (*Configuration) CacheSize

func (c *Configuration) CacheSize(size int64) *Configuration

CacheSize defines local disk cache size for downloaded transcoded videos.

func (*Configuration) HTTPClient

func (c *Configuration) HTTPClient(httpClient HTTPRequester) *Configuration

func (*Configuration) ItemsToPrune added in v0.5.9

func (c *Configuration) ItemsToPrune(i uint32) *Configuration

ItemsToPrune defines how many items to prune during cache cleanup

func (*Configuration) LogLevel added in v0.6.1

func (c *Configuration) LogLevel(l int) *Configuration

LogLevel sets verbosity of logging. `Dev` outputs a lot of debugging info, `Prod` is more restrained.

func (*Configuration) Server

func (c *Configuration) Server(server string) *Configuration

Server sets transcoder server API address.

func (*Configuration) VideoPath

func (c *Configuration) VideoPath(videoPath string) *Configuration

Server sets transcoder server API address.

type Downloadable

type Downloadable interface {
	Download() error
	Progress() <-chan Progress
	Done() bool
}

type HLSStream

type HLSStream struct {
	URL string

	SDHash string
	// contains filtered or unexported fields
}

func (HLSStream) DirName

func (s HLSStream) DirName() string

func (HLSStream) Done added in v0.6.0

func (s HLSStream) Done() bool

func (HLSStream) Download

func (s HLSStream) Download() error

func (HLSStream) LocalPath

func (s HLSStream) LocalPath() string

func (HLSStream) Progress

func (s HLSStream) Progress() <-chan Progress

func (HLSStream) SafeURL

func (s HLSStream) SafeURL() string

type HTTPRequester

type HTTPRequester interface {
	Do(req *http.Request) (res *http.Response, err error)
}

type Progress

type Progress struct {
	Error       error
	BytesLoaded int64
	Stage       int
}

Jump to

Keyboard shortcuts

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