engine

package
v0.0.0-...-bc19bdb Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PeerID            string
	DownloadDirectory string
	EnableUpload      bool
	EnableSeeding     bool
	EnableEncryption  bool
	AutoStart         bool
	IncomingPort      int
	MediaSort         MediaSortConfig `json:"mediaSort"`
}

type Engine

type Engine struct {
	//public torrents
	Torrents map[string]*Torrent
	// contains filtered or unexported fields
}

the Engine Cloud Torrent engine, backed by anacrolix/torrent

func New

func New(storage *storage.Storage) *Engine

func (*Engine) Configure

func (e *Engine) Configure(c *Config) error

func (*Engine) Get

func (e *Engine) Get(hex string) (*Torrent, bool)

func (*Engine) NewByFile

func (e *Engine) NewByFile(body io.Reader) error

func (*Engine) NewByMagnet

func (e *Engine) NewByMagnet(magnetURI string) error

func (*Engine) OpenTorrent

func (e *Engine) OpenTorrent(info *metainfo.Info) torrent.Data

OpenTorrent implements the torrent.Openner interface and Torrent implements the torrent.Data interface

func (*Engine) Remove

func (e *Engine) Remove(rmt *Torrent) error

func (*Engine) Update

func (e *Engine) Update()

GetTorrents copies torrents out of anacrolix/torrent and into the local cache

type File

type File struct {
	//static
	Path string
	Size int64
	//storage state
	Sorted    bool
	NewPath   string
	StorageID string
	//client state
	Started   bool
	Chunks    int
	Completed int
	Percent   float32
	// contains filtered or unexported fields
}

func NewFile

func NewFile(path string, size int64) *File

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (n int, err error)

func (*File) Start

func (f *File) Start(fs storage.Fs) error

func (*File) Stop

func (f *File) Stop() error

func (*File) WriteAt

func (f *File) WriteAt(p []byte, off int64) (n int, err error)

func (*File) WriteSectionTo

func (f *File) WriteSectionTo(w io.Writer, off, n int64) (written int64, err error)

type IHash

type IHash torrent.InfoHash

type MediaSortConfig

type MediaSortConfig struct {
	Enable           bool
	AutoStartMatched bool
	TVDir            string
	MovieDir         string
}

type StorageInfo

type StorageInfo struct {
	ID   string
	Path string
}

type Stream

type Stream struct {
}

func NewStream

func NewStream() *Stream

type Torrent

type Torrent struct {

	//cloud torrent
	Started      bool
	Dropped      bool
	Percent      float32
	DownloadRate float32
	//anacrolix/torrent
	InfoHash   string
	Name       string
	Loaded     bool
	Downloaded int64
	Size       int64
	Files      []*File
	// contains filtered or unexported fields
}

Torrent is converted to JSON and sent to the frontend

func NewTorrent

func NewTorrent(ih string, storage *storage.Storage, sortConfig *MediaSortConfig) *Torrent

func (*Torrent) Close

func (torrent *Torrent) Close()

func (*Torrent) File

func (torrent *Torrent) File(off int64) (*File, int64)

func (*Torrent) Get

func (torrent *Torrent) Get(path string) (*File, bool)

func (*Torrent) PieceComplete

func (torrent *Torrent) PieceComplete(index int) bool

Returns true if the piece is complete.

func (*Torrent) PieceCompleted

func (torrent *Torrent) PieceCompleted(index int) error

We believe the piece data will pass a hash check.

func (*Torrent) ReadAt

func (torrent *Torrent) ReadAt(p []byte, off int64) (n int, err error)

func (*Torrent) Start

func (torrent *Torrent) Start() error

func (*Torrent) Stop

func (torrent *Torrent) Stop() error

func (*Torrent) Update

func (torrent *Torrent) Update(tt torrent.Torrent)

func (*Torrent) WriteAt

func (torrent *Torrent) WriteAt(p []byte, off int64) (n int, err error)

func (*Torrent) WriteSectionTo

func (torrent *Torrent) WriteSectionTo(w io.Writer, off, n int64) (written int64, err error)

If the data isn'tt available, err should be io.ErrUnexpectedEOF.

Jump to

Keyboard shortcuts

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