libtorrent

package
v0.0.0-...-4211eb0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLargestFile

func GetLargestFile(t *torrent.Torrent) *torrent.File

Get largest file inside of a Torrent

func GetVideoFile

func GetVideoFile(t *torrent.Torrent, episode int) (*torrent.File, error)

func TorrentPercentage

func TorrentPercentage(t *torrent.Torrent) float64

Types

type Client

type Client struct {
	// client / project name, will be the default directory name
	Name string
	// directory to download torrents to
	DataDir string
	// Seed or no
	Seed bool
	// Port to stream torrents on
	Port string
	// Port to stream torrents on
	TorrentPort int
	// Default torrent client options
	TorrentClient *torrent.Client

	// torrents
	Torrents []*torrent.Torrent
	// Disable IPV6
	DisableIPV6 bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(name string, port string) *Client

create a default client, must call Init afterwords

func (*Client) AddMagnet

func (c *Client) AddMagnet(magnet string) (*torrent.Torrent, error)

func (*Client) AddTorrent

func (c *Client) AddTorrent(tor string) (*torrent.Torrent, error)

generic add torrent function

func (*Client) AddTorrentFile

func (c *Client) AddTorrentFile(file string) (*torrent.Torrent, error)

func (*Client) AddTorrentURL

func (c *Client) AddTorrentURL(url string) (*torrent.Torrent, error)

func (*Client) Close

func (c *Client) Close() (errs []error)

stops the client and closes all connections to peers

func (*Client) DownloadTorrent

func (c *Client) DownloadTorrent(torrent string) error

func (*Client) DropTorrent

func (c *Client) DropTorrent(t *torrent.Torrent)

func (*Client) FindByInfoHhash

func (c *Client) FindByInfoHhash(infoHash string) (*torrent.Torrent, error)

look through the torrent files the client is handling and return a torrent with a matching info hash

func (*Client) Init

func (c *Client) Init() error

Initialize torrent configuration

func (*Client) ServeTorrent

func (c *Client) ServeTorrent(t *torrent.Torrent, episode int) string

Generate a link that can be used with the default clients server to play a torrent that is already loaded into the client

func (*Client) ServeTorrents

func (c *Client) ServeTorrents(ctx context.Context, torrents []*torrent.Torrent)

func (*Client) ShowTorrents

func (c *Client) ShowTorrents() []*torrent.Torrent

returns a slice of loaded torrents or nil

func (*Client) StartServer

func (c *Client) StartServer()

start the server in the background

type FileEntry

type FileEntry struct {
	*torrent.File
	torrent.Reader
}

FileEntry helps reading a torrent file.

func (*FileEntry) Seek

func (f *FileEntry) Seek(offset int64, whence int) (int64, error)

Seek seeks to the correct file position, paying attention to the offset.

type SeekableContent

type SeekableContent interface {
	io.ReadSeeker
	io.Closer
}

SeekableContent describes an io.ReadSeeker that can be closed as well.

func NewFileReader

func NewFileReader(f *torrent.File) (SeekableContent, error)

NewFileReader sets up a torrent file for streaming reading.

Jump to

Keyboard shortcuts

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