bittorrent

package
v0.1.102 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResumeEmpty ...
	ResumeEmpty = iota
	// ResumeYes ...
	ResumeYes
	// ResumeNo ...
	ResumeNo
)
View Source
const (
	// ResolutionUnknown ...
	ResolutionUnknown = iota
	// Resolution240p ...
	Resolution240p
	// Resolution480p ...
	Resolution480p
	// Resolution720p ...
	Resolution720p
	// Resolution1080p ...
	Resolution1080p
	// Resolution2K ...
	Resolution2K
	// Resolution4k ...
	Resolution4k
)
View Source
const (
	// RipUnknown ...
	RipUnknown = iota
	// RipCam ...
	RipCam
	// RipTS ...
	RipTS
	// RipTC ...
	RipTC
	// RipScr ...
	RipScr
	// RipDVDScr ...
	RipDVDScr
	// RipDVD ...
	RipDVD
	// RipHDTV ...
	RipHDTV
	// RipWeb ...
	RipWeb
	// RipBluRay ...
	RipBluRay
)
View Source
const (
	// RatingUnkown ...
	RatingUnkown = iota
	// RatingProper ...
	RatingProper
	// RatingNuked ...
	RatingNuked
)
View Source
const (
	// CodecUnknown ...
	CodecUnknown = iota

	// CodecXVid ...
	CodecXVid
	// CodecH264 ...
	CodecH264
	// CodecH265 ...
	CodecH265

	// CodecMp3 ...
	CodecMp3
	// CodecAAC ...
	CodecAAC
	// CodecAC3 ...
	CodecAC3
	// CodecDTS ...
	CodecDTS
	// CodecDTSHD ...
	CodecDTSHD
	// CodecDTSHDMA ...
	CodecDTSHDMA
)
View Source
const (
	// DownloadFilePlaying ...
	DownloadFilePlaying int = iota
	// DownloadFileSeason ...
	DownloadFileSeason
	// DownloadFileAll ...
	DownloadFileAll
)
View Source
const (
	// StatusQueued ...
	StatusQueued = iota
	// StatusChecking ...
	StatusChecking
	// StatusFinding ...
	StatusFinding
	// StatusDownloading ...
	StatusDownloading
	// StatusFinished ...
	StatusFinished
	// StatusSeeding ...
	StatusSeeding
	// StatusAllocating ...
	StatusAllocating
	// StatusStalled ...
	StatusStalled
	// StatusPaused ...
	StatusPaused
	// StatusBuffering ...
	StatusBuffering
	// StatusPlaying ...
	StatusPlaying
)
View Source
const (
	// Remove ...
	Remove = iota
	// Active ...
	Active
)
View Source
const (
	// ProxyTypeNone ...
	ProxyTypeNone = iota
	// ProxyTypeSocks4 ...
	ProxyTypeSocks4
	// ProxyTypeSocks5 ...
	ProxyTypeSocks5
	// ProxyTypeSocks5Password ...
	ProxyTypeSocks5Password
	// ProxyTypeSocksHTTP ...
	ProxyTypeSocksHTTP
	// ProxyTypeSocksHTTPPassword ...
	ProxyTypeSocksHTTPPassword
	// ProxyTypeI2PSAM ...
	ProxyTypeI2PSAM
)

Variables

View Source
var (

	// Resolutions ...
	Resolutions = []string{"", "240p", "480p", "720p", "1080p", "2K", "4K"}
	// Colors ...
	Colors = []string{"", "FFFC3401", "FFA56F01", "FF539A02", "FF0166FC", "FFF15052", "FF6BB9EC"}
)
View Source
var (

	// Codecs ...
	Codecs = []string{"", "Xvid", "H.264", "H.265", "MP3", "AAC", "AC3", "DTS", "DTS HD", "DTS HD MA"}
)
View Source
var (

	// Rips ...
	Rips = []string{"", "Cam", "TeleSync", "TeleCine", "Screener", "DVD Screener", "DVDRip", "HDTV", "WebDL", "Blu-Ray"}
)
View Source
var StatusStrings = []string{
	"LOCALIZE[30621]",
	"LOCALIZE[30622]",
	"LOCALIZE[30623]",
	"LOCALIZE[30624]",
	"LOCALIZE[30625]",
	"LOCALIZE[30626]",
	"LOCALIZE[30627]",
	"LOCALIZE[30628]",
	"LOCALIZE[30629]",
	"LOCALIZE[30630]",
	"LOCALIZE[30631]",
}

StatusStrings ...

Functions

func DebugAll

func DebugAll(s *Service) gin.HandlerFunc

func DebugBundle

func DebugBundle(s *Service) gin.HandlerFunc

DebugBundle ...

func IsWatchedFile

func IsWatchedFile(path string, size int64) bool

IsWatchedFile ...

func MatchEpisodeFilename

func MatchEpisodeFilename(s, e int, isSingleSeason bool, activeSeason int, show *tmdb.Show, episode *tmdb.Episode, tvdbShow *tvdb.Show, choices []*CandidateFile) (index, found int)

MatchEpisodeFilename matches season and episode in the filename to get ocurrence

func SetWatchedFile

func SetWatchedFile(path string, size int64, watched bool)

SetWatchedFile ...

func TrimChoices

func TrimChoices(choices []*CandidateFile)

TrimChoices clears redundant folder names from files list and sorts remaining records.

func URLForHTTP

func URLForHTTP(pattern string, args ...interface{}) string

URLForHTTP ...

func URLForXBMC

func URLForXBMC(pattern string, args ...interface{}) string

URLForXBMC ...

func URLQuery

func URLQuery(route string, query ...string) string

URLQuery ...

func UpdateDefaultTrackers

func UpdateDefaultTrackers()

UpdateDefaultTrackers fetches extra trackers from predefined page

Types

type Action

type Action int32

Action ...

const (
	// ActionConnect ...
	ActionConnect Action = iota
	// ActionAnnounce ...
	ActionAnnounce
	// ActionScrape ...
	ActionScrape
	// ActionError ...
	ActionError = 50331648 // it's LittleEndian(3), in BigEndian, don't ask
)

type AddOptions

type AddOptions struct {
	URI             string
	Paused          bool
	DownloadStorage int
	FirstTime       bool
	AddedTime       time.Time
}

AddOptions is setting options for different torrent add procedures

type Alert

type Alert struct {
	Type     int
	Category int
	What     string
	Message  string
	Pointer  uintptr
	Name     string
	Entry    lt.Entry
	InfoHash string
}

Alert ...

type AnnounceRequest

type AnnounceRequest struct {
	InfoHash   [20]byte
	PeerID     [20]byte
	Downloaded int64
	Left       int64
	Uploaded   int64
	Event      int32
	IPAddress  int32
	Key        int32
	NumWant    int32
	Port       int16
}

AnnounceRequest ...

type AnnounceResponse

type AnnounceResponse struct {
	Interval int32
	Leechers int32
	Seeders  int32
}

AnnounceResponse ...

type Bitfield

type Bitfield []byte

Bitfield ...

func (Bitfield) GetBit

func (b Bitfield) GetBit(idx int) bool

GetBit ...

func (Bitfield) SetBit

func (b Bitfield) SetBit(idx int, value bool)

SetBit ...

func (Bitfield) String

func (b Bitfield) String() string

String ...

type CandidateFile

type CandidateFile struct {
	Index       int
	Filename    string
	DisplayName string
	Path        string
	Size        int64
}

CandidateFile ...

type ConnectionResponse

type ConnectionResponse struct {
	ConnectionID int64
}

ConnectionResponse ...

type File

type File struct {
	Selected   bool
	Index      int
	Name       string
	Size       int64
	Path       string
	Offset     int64
	PieceStart int
	PieceEnd   int
}

File ...

type MemoryFile

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

MemoryFile ...

func NewMemoryFile

func NewMemoryFile(tf *TorrentFS, storage lt.MemoryStorage, file *File, path string) *MemoryFile

NewMemoryFile ...

func (*MemoryFile) Close

func (mf *MemoryFile) Close() (err error)

Close ...

func (*MemoryFile) IsDir

func (mf *MemoryFile) IsDir() bool

IsDir ...

func (*MemoryFile) ModTime

func (mf *MemoryFile) ModTime() time.Time

ModTime ...

func (*MemoryFile) Mode

func (mf *MemoryFile) Mode() os.FileMode

Mode ...

func (*MemoryFile) Name

func (mf *MemoryFile) Name() string

Name ...

func (*MemoryFile) Read

func (mf *MemoryFile) Read(b []byte) (n int, err error)

Read ...

func (*MemoryFile) ReadPiece

func (mf *MemoryFile) ReadPiece(b []byte, piece int, pieceOffset int) (n int, err error)

ReadPiece ...

func (*MemoryFile) Readdir

func (mf *MemoryFile) Readdir(count int) (ret []os.FileInfo, err error)

Readdir ...

func (*MemoryFile) Seek

func (mf *MemoryFile) Seek(off int64, whence int) (ret int64, err error)

Seek ...

func (*MemoryFile) Size

func (mf *MemoryFile) Size() int64

Size ...

func (*MemoryFile) Stat

func (mf *MemoryFile) Stat() (ret os.FileInfo, err error)

Stat ...

func (*MemoryFile) Sys

func (mf *MemoryFile) Sys() interface{}

Sys ...

type NextEpisode

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

NextEpisode ...

type Peer

type Peer struct {
	IPAddress int32
	Port      int16
}

Peer ...

type PieceRange

type PieceRange struct {
	Begin, End int
}

PieceRange ...

type Player

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

Player ...

func NewPlayer

func NewPlayer(bts *Service, params PlayerParams, xbmcHost *xbmc.XBMCHost) *Player

NewPlayer ...

func (*Player) Buffer

func (btp *Player) Buffer() error

Buffer ...

func (*Player) Close

func (btp *Player) Close()

Close ...

func (*Player) DownloadSubtitles

func (btp *Player) DownloadSubtitles()

DownloadSubtitles ...

func (*Player) FetchStoredResume

func (btp *Player) FetchStoredResume()

FetchStoredResume ...

func (*Player) GetIdent

func (btp *Player) GetIdent()

GetIdent tries to find playing item in Kodi library

func (*Player) GetTorrent

func (btp *Player) GetTorrent() *Torrent

GetTorrent ...

func (*Player) GetXBMCHost

func (btp *Player) GetXBMCHost() *xbmc.XBMCHost

func (*Player) HasChosenFile

func (btp *Player) HasChosenFile() bool

HasChosenFile ...

func (*Player) InitAudio

func (btp *Player) InitAudio()

InitAudio ...

func (*Player) InitSubtitles

func (btp *Player) InitSubtitles()

InitSubtitles ...

func (*Player) IsClosed

func (btp *Player) IsClosed() bool

IsClosed returns whether player is in closing stage

func (*Player) IsWatched

func (btp *Player) IsWatched() bool

IsWatched ...

func (*Player) Params

func (btp *Player) Params() *PlayerParams

Params returns Params for external use

func (*Player) PlayURL

func (btp *Player) PlayURL() string

PlayURL ...

func (*Player) SaveStoredResume

func (btp *Player) SaveStoredResume()

SaveStoredResume ...

func (*Player) SetSubtitles

func (btp *Player) SetSubtitles()

SetSubtitles ...

func (*Player) SetTorrent

func (btp *Player) SetTorrent(t *Torrent)

SetTorrent ...

func (*Player) UpdateWatched

func (btp *Player) UpdateWatched()

UpdateWatched is updating watched progress is Kodi

type PlayerParams

type PlayerParams struct {
	Playing           bool
	Paused            bool
	Seeked            bool
	WasPlaying        bool
	WasSeeked         bool
	DoneAudio         bool
	DoneSubtitles     bool
	Background        bool
	KodiPosition      int
	WatchedProgress   float64
	WatchedTime       float64
	VideoDuration     float64
	URI               string
	OriginalIndex     int
	FileIndex         int
	NextOriginalIndex int
	NextFileIndex     int
	ResumeToken       string
	ResumeHash        string
	ResumePlayback    int
	TraktScrobbled    bool
	ContentType       string
	KodiID            int
	TMDBId            int
	ShowID            int
	Season            int
	Episode           int
	AbsoluteNumber    int
	Query             string
	UpNextSent        bool
	UIDs              *uid.UniqueIDs
	Resume            *uid.Resume
	StoredResume      *uid.Resume
}

PlayerParams ...

type Queue

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

Queue represents list of torrents inside of a session

func NewQueue

func NewQueue(s *Service) *Queue

NewQueue contructor for empty Queue

func (*Queue) Add

func (q *Queue) Add(t *Torrent) bool

Add torrent to the queue

func (*Queue) All

func (q *Queue) All() []*Torrent

All returns all queue

func (*Queue) Clean

func (q *Queue) Clean()

Clean would cleanup torrents list, should be used in case of a service reload

func (*Queue) Delete

func (q *Queue) Delete(t *Torrent) bool

Delete removes torrent from the queue

func (*Queue) FindByHash

func (q *Queue) FindByHash(hash string) *Torrent

FindByHash checks if torrent with infohash is in the queue

func (*Queue) FindByURI

func (q *Queue) FindByURI(uri string) *Torrent

FindByURI checks if torrent with infohash is in the queue

type RemoveOptions

type RemoveOptions struct {
	ForceKeepTorrentData bool
	ForceDrop            bool
	ForceDelete          bool
	IsWatched            bool
}

RemoveOptions is setting options for different torrent removal procedures

type ScrapeResponseEntry

type ScrapeResponseEntry struct {
	Seeders   int32
	Completed int32
	Leechers  int32
}

ScrapeResponseEntry ...

type Service

type Service struct {
	Session       lt.SessionHandle
	SessionGlobal lt.Session
	PackSettings  lt.SettingsPack

	InternalProxy *proxy.CustomProxy

	Players      map[string]*Player
	SpaceChecked map[string]bool

	UserAgent   string
	PeerID      string
	ListenIP    string
	ListenIPv6  string
	ListenPort  int
	DisableIPv6 bool

	Closer         event.Event
	CloserNotifier event.Event
	// contains filtered or unexported fields
}

Service ...

func NewService

func NewService() *Service

NewService ...

func (*Service) AddTorrent

func (s *Service) AddTorrent(xbmcHost *xbmc.XBMCHost, options AddOptions) (*Torrent, error)

AddTorrent ...

func (*Service) Alerts

func (s *Service) Alerts() (<-chan *Alert, chan<- interface{})

Alerts ...

func (*Service) AttachPlayer

func (s *Service) AttachPlayer(p *Player)

AttachPlayer adds Player instance to service

func (*Service) ClientInfo

func (s *Service) ClientInfo(ctx *gin.Context)

ClientInfo ...

func (*Service) Close

func (s *Service) Close(isShutdown bool)

Close ...

func (*Service) CloseSession

func (s *Service) CloseSession()

CloseSession tries to close libtorrent session with a timeout, because it takes too much to close and Kodi hangs.

func (*Service) DetachPlayer

func (s *Service) DetachPlayer(p *Player)

DetachPlayer removes Player instance

func (*Service) GetActivePlayer

func (s *Service) GetActivePlayer() *Player

GetActivePlayer searches for player that is Playing anything

func (*Service) GetBufferSize

func (s *Service) GetBufferSize() int64

GetBufferSize ...

func (*Service) GetListenIP

func (s *Service) GetListenIP(network string) string

GetListenIP returns calculated IP for TCP/TCP6

func (*Service) GetMemorySize

func (s *Service) GetMemorySize() int64

GetMemorySize ...

func (*Service) GetMemoryStats

func (s *Service) GetMemoryStats() (int64, int64)

GetMemoryStats returns total and free memory sizes for this OS

func (*Service) GetPlayer

func (s *Service) GetPlayer(kodiID int, tmdbID int) *Player

GetPlayer searches for player with desired TMDB id

func (*Service) GetSeedTime

func (s *Service) GetSeedTime() int64

GetSeedTime ...

func (*Service) GetStorageType

func (s *Service) GetStorageType() int

GetStorageType ...

func (*Service) GetTorrentByHash

func (s *Service) GetTorrentByHash(hash string) *Torrent

GetTorrentByHash ...

func (*Service) GetTorrentByURI

func (s *Service) GetTorrentByURI(uri string) *Torrent

GetTorrentByURI ...

func (*Service) GetTorrents

func (s *Service) GetTorrents() []*Torrent

GetTorrents return all active torrents

func (*Service) HasTorrentByEpisode

func (s *Service) HasTorrentByEpisode(tmdbID int, season, episode int) *Torrent

HasTorrentByEpisode checks whether there is active torrent for queried episode

func (*Service) HasTorrentByFakeID

func (s *Service) HasTorrentByFakeID(query string) *Torrent

HasTorrentByFakeID checks whether there is active torrent with fake id

func (*Service) HasTorrentByID

func (s *Service) HasTorrentByID(tmdbID int) *Torrent

HasTorrentByID checks whether there is active torrent for queried tmdb id

func (*Service) HasTorrentByName

func (s *Service) HasTorrentByName(query string) *Torrent

HasTorrentByName checks whether there is active torrent for queried name

func (*Service) HasTorrentByQuery

func (s *Service) HasTorrentByQuery(query string) *Torrent

HasTorrentByQuery checks whether there is active torrent with searches query

func (*Service) HasTorrentBySeason

func (s *Service) HasTorrentBySeason(tmdbID int, season int) *Torrent

HasTorrentBySeason checks whether there is active torrent for queried season

func (*Service) IsMemoryStorage

func (s *Service) IsMemoryStorage() bool

IsMemoryStorage is a shortcut for checking whether we run memory storage

func (*Service) PlayerSeek

func (s *Service) PlayerSeek()

PlayerSeek ...

func (*Service) PlayerStop

func (s *Service) PlayerStop()

PlayerStop ...

func (*Service) Reconfigure

func (s *Service) Reconfigure()

Reconfigure fired every time addon configuration has changed and Kodi sent a notification about that. Should reassemble Service configuration and restart everything. For non-memory storage it should also load old torrent files.

func (*Service) RemoveTorrent

func (s *Service) RemoveTorrent(xbmcHost *xbmc.XBMCHost, t *Torrent, flags RemoveOptions) bool

RemoveTorrent ...

func (*Service) RestoreLimits

func (s *Service) RestoreLimits()

RestoreLimits ...

func (*Service) SetBufferingLimits

func (s *Service) SetBufferingLimits()

SetBufferingLimits ...

func (*Service) SetDownloadLimit

func (s *Service) SetDownloadLimit(i int)

SetDownloadLimit ...

func (*Service) SetUploadLimit

func (s *Service) SetUploadLimit(i int)

SetUploadLimit ...

func (*Service) StopNextFiles

func (s *Service) StopNextFiles()

StopNextFiles stops all torrents that wait for "next" playback

type Torrent

type Torrent struct {
	DownloadStorage int

	ChosenFiles []*File

	Service *Service

	BufferLength           int64
	BufferProgress         float64
	BufferProgressPrevious float64
	BufferPiecesLength     int64
	BufferPiecesProgress   map[int]float64
	MemorySize             int64

	IsMoveInProgress         bool
	IsMarkedToMove           bool
	IsPlaying                bool
	IsPaused                 bool
	IsBuffering              bool
	IsBufferingFinished      bool
	IsSeeding                bool
	IsRarArchive             bool
	IsNextFile               bool
	IsNeedFinishNotification bool
	HasNextFile              bool
	PlayerAttached           int

	DBItem *database.BTItem

	Closer event.Event
	// contains filtered or unexported fields
}

Torrent ...

func NewTorrent

func NewTorrent(service *Service, handle lt.TorrentHandle, info lt.TorrentInfo, path string, downloadStorage int) *Torrent

NewTorrent ...

func (*Torrent) AdjustMemorySize

func (t *Torrent) AdjustMemorySize(ms int64)

AdjustMemorySize ...

func (*Torrent) AlertFinished

func (t *Torrent) AlertFinished()

AlertFinished sends notification to user that this torrent is successfully downloaded

func (*Torrent) Buffer

func (t *Torrent) Buffer(file *File, isStartup bool)

Buffer defines buffer pieces for downloading prior to sending file to Kodi. Kodi sends two requests, one for onecoming file read handler, another for a piece of file from the end (probably to get codec descriptors and so on) We set it as post-buffer and include in required buffer pieces array.

func (*Torrent) ChooseFile

func (t *Torrent) ChooseFile(btp *Player) (*File, int, error)

ChooseFile opens file selector if not provided with Player, otherwise tries to detect what to open.

func (*Torrent) ClearDeadlines

func (t *Torrent) ClearDeadlines()

ClearDeadlines ...

func (*Torrent) CloseReaders

func (t *Torrent) CloseReaders()

CloseReaders ...

func (*Torrent) DownloadAllFiles

func (t *Torrent) DownloadAllFiles()

DownloadAllFiles ...

func (*Torrent) DownloadFile

func (t *Torrent) DownloadFile(addFile *File)

DownloadFile ...

func (*Torrent) DownloadFileWithPriority

func (t *Torrent) DownloadFileWithPriority(addFile *File, priority int)

DownloadFileWithPriority ...

func (*Torrent) DownloadFiles

func (t *Torrent) DownloadFiles(files []*File)

DownloadFiles sets priority 1 to list of files

func (*Torrent) Drop

func (t *Torrent) Drop(removeFiles, removeData bool)

Drop ...

func (*Torrent) FetchDBItem

func (t *Torrent) FetchDBItem() *database.BTItem

FetchDBItem ...

func (*Torrent) GetAddedTime

func (t *Torrent) GetAddedTime() time.Time

GetAddedTime ...

func (*Torrent) GetBufferProgress

func (t *Torrent) GetBufferProgress() float64

GetBufferProgress ...

func (*Torrent) GetCandidateFileForIndex

func (t *Torrent) GetCandidateFileForIndex(idx int) *CandidateFile

GetCandidateFileForIndex returns CandidateFile for specific int index

func (*Torrent) GetCandidateFiles

func (t *Torrent) GetCandidateFiles(btp *Player) ([]*CandidateFile, int, error)

GetCandidateFiles returns all the files for selecting by user

func (*Torrent) GetConnections

func (t *Torrent) GetConnections() (int, int, int, int)

GetConnections returns connected and overall number of peers

func (*Torrent) GetDBItem

func (t *Torrent) GetDBItem() *database.BTItem

GetDBItem ...

func (*Torrent) GetFileByIndex

func (t *Torrent) GetFileByIndex(q int) *File

GetFileByIndex ...

func (*Torrent) GetFileByPath

func (t *Torrent) GetFileByPath(q string) *File

GetFileByPath ...

func (*Torrent) GetFilePieces

func (t *Torrent) GetFilePieces(files lt.FileStorage, idx int) (ret PieceRange)

GetFilePieces ...

func (*Torrent) GetFiles

func (t *Torrent) GetFiles() []*File

GetFiles returns all files of a torrent

func (*Torrent) GetHandle

func (t *Torrent) GetHandle() lt.TorrentHandle

GetHandle ...

func (*Torrent) GetHumanizedSpeeds

func (t *Torrent) GetHumanizedSpeeds() (down, up string)

GetHumanizedSpeeds returns humanize download and upload speeds

func (*Torrent) GetLastStatus

func (t *Torrent) GetLastStatus(isForced bool) lt.TorrentStatus

GetLastStatus gets, or initially sets torrenthandle status

func (*Torrent) GetMetadata

func (t *Torrent) GetMetadata() []byte

GetMetadata ...

func (*Torrent) GetNextEpisodeFile

func (t *Torrent) GetNextEpisodeFile(season, episode int) *File

GetNextEpisodeFile ...

func (*Torrent) GetNextSingleEpisodeFile

func (t *Torrent) GetNextSingleEpisodeFile(episode int) *File

GetNextSingleEpisodeFile ...

func (*Torrent) GetOldTorrent

func (t *Torrent) GetOldTorrent() (*TorrentFile, error)

GetOldTorrent gets old torrent from the database

func (*Torrent) GetPaused

func (t *Torrent) GetPaused() bool

GetPaused ...

func (*Torrent) GetPlayURL

func (t *Torrent) GetPlayURL(fileIndex string) string

GetPlayURL returns url ready for Kodi

func (*Torrent) GetProgress

func (t *Torrent) GetProgress() float64

GetProgress ...

func (*Torrent) GetReadaheadSize

func (t *Torrent) GetReadaheadSize() (ret int64)

GetReadaheadSize ...

func (*Torrent) GetRealProgress

func (t *Torrent) GetRealProgress() float64

GetRealProgress returns progress of downloading in libtorrent. Should be taken in mind that for memory storage it's a progress of downloading currently active pieces, not the whole torrent.

func (*Torrent) GetSelectedSize

func (t *Torrent) GetSelectedSize() int64

GetSelectedSize returns size of all chosen files

func (*Torrent) GetSmartState

func (t *Torrent) GetSmartState() int

GetSmartState ...

func (*Torrent) GetSpeeds

func (t *Torrent) GetSpeeds() (down, up int)

GetSpeeds returns download and upload speeds

func (*Torrent) GetState

func (t *Torrent) GetState() int

GetState ...

func (*Torrent) GetStatus

func (t *Torrent) GetStatus() lt.TorrentStatus

GetStatus ...

func (*Torrent) GotInfo

func (t *Torrent) GotInfo() <-chan struct{}

GotInfo ...

func (*Torrent) HasAvailableFiles

func (t *Torrent) HasAvailableFiles() bool

HasAvailableFiles ...

func (*Torrent) HasMetadata

func (t *Torrent) HasMetadata() bool

HasMetadata ...

func (*Torrent) InfoHash

func (t *Torrent) InfoHash() string

InfoHash ...

func (*Torrent) IsMemoryStorage

func (t *Torrent) IsMemoryStorage() bool

IsMemoryStorage is a shortcut for checking whether we run memory storage

func (*Torrent) Length

func (t *Torrent) Length() int64

Length ...

func (*Torrent) MakeFiles

func (t *Torrent) MakeFiles()

MakeFiles ...

func (*Torrent) Name

func (t *Torrent) Name() string

Name ...

func (*Torrent) Pause

func (t *Torrent) Pause()

Pause ...

func (*Torrent) PrioritizePiece

func (t *Torrent) PrioritizePiece(piece int)

PrioritizePiece ...

func (*Torrent) PrioritizePieces

func (t *Torrent) PrioritizePieces()

PrioritizePieces ...

func (*Torrent) ReadersReadaheadSum

func (t *Torrent) ReadersReadaheadSum() int64

ReadersReadaheadSum ...

func (*Torrent) ResetBuffering

func (t *Torrent) ResetBuffering()

ResetBuffering resets all fields related to buffering

func (*Torrent) ResetReaders

func (t *Torrent) ResetReaders()

ResetReaders ...

func (*Torrent) Resume

func (t *Torrent) Resume()

Resume ...

func (*Torrent) SaveDBFiles

func (t *Torrent) SaveDBFiles()

SaveDBFiles ...

func (*Torrent) SaveMetainfo

func (t *Torrent) SaveMetainfo(path string) (string, error)

SaveMetainfo ...

func (*Torrent) SelectDownloadFiles

func (t *Torrent) SelectDownloadFiles(btp *Player)

SelectDownloadFiles selects files for download, according to setting

func (*Torrent) Storage

func (t *Torrent) Storage() lt.StorageInterface

Storage ...

func (*Torrent) SyncSelectedFiles

func (t *Torrent) SyncSelectedFiles() []string

SyncSelectedFiles iterates through torrent files and choosing selected files

func (*Torrent) Title

func (t *Torrent) Title() string

Title returns name of a torrent, or, if present, how it looked in plugin that found it.

func (*Torrent) TorrentInfo

func (t *Torrent) TorrentInfo(xbmcHost *xbmc.XBMCHost, w io.Writer, showTrackers, showPieces bool)

TorrentInfo writes torrent status to io.Writer

func (*Torrent) UnDownloadAllFiles

func (t *Torrent) UnDownloadAllFiles()

UnDownloadAllFiles ...

func (*Torrent) UnDownloadFile

func (t *Torrent) UnDownloadFile(addFile *File) bool

UnDownloadFile ...

func (*Torrent) UndownloadFiles

func (t *Torrent) UndownloadFiles(files []*File)

UndownloadFiles sets priority 0 to list of files

func (*Torrent) UpdateDatabaseMetadata

func (t *Torrent) UpdateDatabaseMetadata(in []byte) ([]byte, error)

UpdateDatabaseMetadata in decoding torrent bencoded, adding proper Title and then returning encoded bencoded.

func (*Torrent) UpdateMetadataTitle

func (t *Torrent) UpdateMetadataTitle(title string, in []byte) []byte

UpdateMetadataTitle ...

func (*Torrent) UpdateTorrentMetadata

func (t *Torrent) UpdateTorrentMetadata() error

UpdateTorrentMetadata updates metadata for specific TMDB id

func (*Torrent) WaitForMetadata

func (t *Torrent) WaitForMetadata(xbmcHost *xbmc.XBMCHost, infoHash string) (err error)

WaitForMetadata waits for getting torrent information or cancels if torrent is closed

func (*Torrent) Watch

func (t *Torrent) Watch()

Watch ...

type TorrentFS

type TorrentFS struct {
	http.Dir
	// contains filtered or unexported fields
}

TorrentFS ...

func NewTorrentFS

func NewTorrentFS(service *Service, method string) *TorrentFS

NewTorrentFS ...

func (*TorrentFS) Open

func (tfs *TorrentFS) Open(uname string) (http.File, error)

Open ...

type TorrentFSEntry

type TorrentFSEntry struct {
	http.File
	// contains filtered or unexported fields
}

TorrentFSEntry ...

func NewTorrentFSEntry

func NewTorrentFSEntry(file http.File, tfs *TorrentFS, t *Torrent, f *File, name string) (*TorrentFSEntry, error)

NewTorrentFSEntry ...

func (*TorrentFSEntry) Close

func (tf *TorrentFSEntry) Close() error

Close ...

func (*TorrentFSEntry) IsActive

func (tf *TorrentFSEntry) IsActive() bool

IsActive ...

func (*TorrentFSEntry) IsHead

func (tf *TorrentFSEntry) IsHead() bool

IsHead ...

func (*TorrentFSEntry) IsIdle

func (tf *TorrentFSEntry) IsIdle() bool

IsIdle ...

func (*TorrentFSEntry) Pos

func (tf *TorrentFSEntry) Pos() (int64, error)

Pos returns current file position

func (*TorrentFSEntry) Read

func (tf *TorrentFSEntry) Read(data []byte) (n int, err error)

Read ...

func (*TorrentFSEntry) Readahead

func (tf *TorrentFSEntry) Readahead() int64

Readahead returns current reader readahead

func (*TorrentFSEntry) ReaderPiecesRange

func (tf *TorrentFSEntry) ReaderPiecesRange() (ret PieceRange)

ReaderPiecesRange ...

func (*TorrentFSEntry) Seek

func (tf *TorrentFSEntry) Seek(offset int64, whence int) (int64, error)

Seek ...

func (*TorrentFSEntry) SetActive

func (tf *TorrentFSEntry) SetActive(is bool) (res bool)

SetActive ...

type TorrentFile

type TorrentFile struct {
	URI        string   `json:"uri"`
	InfoHash   string   `json:"info_hash"`
	Title      string   `json:"title"`
	Name       string   `json:"name"`
	Trackers   []string `json:"trackers"`
	Size       string   `json:"size"`
	SizeParsed uint64   `jsin:"-"`
	Seeds      int64    `json:"seeds"`
	Peers      int64    `json:"peers"`
	IsPrivate  bool     `json:"is_private"`
	Provider   string   `json:"provider"`
	Icon       string   `json:"icon"`
	Multi      bool

	Resolution  int    `json:"resolution"`
	VideoCodec  int    `json:"video_codec"`
	AudioCodec  int    `json:"audio_codec"`
	Language    string `json:"language"`
	RipType     int    `json:"rip_type"`
	SceneRating int    `json:"scene_rating"`
	// contains filtered or unexported fields
}

TorrentFile represents a physical torrent file

func NewTorrentFile

func NewTorrentFile(uri string) *TorrentFile

NewTorrentFile ...

func (*TorrentFile) Download

func (t *TorrentFile) Download() ([]byte, error)

Download takes care about torrent's URI and downloads or reads cached file

func (*TorrentFile) EnrichTrackers

func (t *TorrentFile) EnrichTrackers()

EnrichTrackers ...

func (*TorrentFile) GenerateFileName

func (t *TorrentFile) GenerateFileName() string

GenerateFileName ...

func (*TorrentFile) IsMagnet

func (t *TorrentFile) IsMagnet() bool

IsMagnet ...

func (*TorrentFile) IsValidMagnet

func (t *TorrentFile) IsValidMagnet() (err error)

IsValidMagnet Taken from anacrolix/torrent

func (*TorrentFile) LoadFromBytes

func (t *TorrentFile) LoadFromBytes(in []byte) error

LoadFromBytes ...

func (*TorrentFile) Magnet

func (t *TorrentFile) Magnet(firstTime bool)

Magnet ...

func (*TorrentFile) MarshalJSON

func (t *TorrentFile) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*TorrentFile) Resolve

func (t *TorrentFile) Resolve() error

Resolve ...

func (*TorrentFile) SaveToFile

func (t *TorrentFile) SaveToFile(b []byte) error

SaveToFile will save torrent to .torrent file for libtorrent

func (*TorrentFile) StreamInfo

func (t *TorrentFile) StreamInfo() *xbmc.StreamInfo

StreamInfo ...

func (*TorrentFile) UnmarshalJSON

func (t *TorrentFile) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (*TorrentFile) UpdateTorrentTrackers

func (t *TorrentFile) UpdateTorrentTrackers() error

UpdateTorrentTrackers updates raw torrent file trackers

type TorrentFileRaw

type TorrentFileRaw struct {
	Title        string                 `bencode:"title"`
	Announce     string                 `bencode:"announce"`
	AnnounceList [][]string             `bencode:"announce-list"`
	Info         map[string]interface{} `bencode:"info"`
}

TorrentFileRaw ...

func (TorrentFileRaw) HasAnnounce

func (t TorrentFileRaw) HasAnnounce(tracker string) bool

HasAnnounce checks AnnounceList for specific tracker

type Tracker

type Tracker struct {
	URL *url.URL
	// contains filtered or unexported fields
}

Tracker ...

func NewTracker

func NewTracker(trackerURL string) (tracker *Tracker, err error)

NewTracker ...

func (*Tracker) Connect

func (tracker *Tracker) Connect() error

Connect ...

func (*Tracker) Scrape

func (tracker *Tracker) Scrape(torrents []*TorrentFile) []ScrapeResponseEntry

Scrape ...

func (*Tracker) String

func (tracker *Tracker) String() string

type TrackerRequest

type TrackerRequest struct {
	ConnectionID  int64
	Action        Action
	TransactionID int32
}

TrackerRequest ...

type TrackerResponse

type TrackerResponse struct {
	Action        Action
	TransactionID int32
}

TrackerResponse ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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