bittorrent

package
v0.0.0-...-29a3764 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

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 (
	// StorageFile ...
	StorageFile int = iota
	// StorageMemory ...
	StorageMemory
)
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 DefaultTrackers = []string{
	"http://bt4.t-ru.org/ann?magnet",
	"http://retracker.mgts.by:80/announce",
	"http://tracker.city9x.com:2710/announce",
	"http://tracker.electro-torrent.pl:80/announce",
	"http://tracker.internetwarriors.net:1337/announce",
	"http://bt.svao-ix.ru/announce",

	"udp://tracker.opentrackr.org:1337/announce",
	"udp://tracker.coppersurfer.tk:6969/announce",
	"udp://tracker.leechers-paradise.org:6969/announce",
	"udp://tracker.openbittorrent.com:80/announce",
	"udp://public.popcorn-tracker.org:6969/announce",
	"udp://explodie.org:6969",
	"udp://46.148.18.250:2710",
	"udp://opentor.org:2710",
}

DefaultTrackers ...

View Source
var (

	// Rips ...
	Rips = []string{"", "Cam", "TeleSync", "TeleCine", "Screener", "DVD Screener", "DVDRip", "HDTV", "WebDL", "Blu-Ray"}
)
View Source
var StatusStrings = []string{
	"Queued",
	"Checking",
	"Finding",
	"Downloading",
	"Finished",
	"Seeding",
	"Allocating",
	"Stalled",
	"Paused",
	"Buffering",
	"Playing",
}

StatusStrings ...

View Source
var (
	// Storages ...
	Storages = []string{
		"File",
		"Memory",
	}
)

Functions

func DebugAll

func DebugAll(s *Service) http.Handler

DebugAll ...

func DebugBundle

func DebugBundle(s *Service) http.Handler

DebugBundle ...

func IsWatchedFile

func IsWatchedFile(path string, size int64) bool

IsWatchedFile ...

func MatchEpisodeFilename

func MatchEpisodeFilename(s, e int, isSingleSeason bool, 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 ...

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 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) *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) 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) 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   int
	WatchedTime       float64
	VideoDuration     float64
	URI               string
	OriginalIndex     int
	FileIndex         int
	NextOriginalIndex int
	NextFileIndex     int
	ResumeToken       string
	ResumeHash        string
	ResumePlayback    bool
	TraktScrobbled    bool
	ContentType       string
	KodiID            int
	TMDBId            int
	ShowID            int
	Season            int
	Episode           int
	AbsoluteNumber    int
	Query             string
	UIDs              *library.UniqueIDs
	Resume            *library.Resume
	StoredResume      *library.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

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 *http.Server

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

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

	MarkedToMove string

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

Service ...

func NewService

func NewService() *Service

NewService ...

func (*Service) AddTorrent

func (s *Service) AddTorrent(uri string, paused bool) (*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(_w io.Writer)

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) 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(t *Torrent, forceDrop, forceDelete, isWatched bool) 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 {
	ChosenFiles []*File
	TorrentPath string

	Service *Service

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

	IsPlaying           bool
	IsPaused            bool
	IsBuffering         bool
	IsBufferingFinished bool
	IsSeeding           bool
	IsRarArchive        bool
	IsNextFile          bool
	HasNextFile         bool
	PlayerAttached      int

	DBItem *database.BTItem

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

Torrent ...

func NewTorrent

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

NewTorrent ...

func (*Torrent) AdjustMemorySize

func (t *Torrent) AdjustMemorySize(ms int64)

AdjustMemorySize ...

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) Drop

func (t *Torrent) Drop(removeFiles 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) 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) GetMetadata

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

GetMetadata ...

func (*Torrent) GetNextEpisodeFile

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

GetNextEpisodeFile ...

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) 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) GetStateString

func (t *Torrent) GetStateString() string

GetStateString ...

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) 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) 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) error

SaveMetainfo ...

func (*Torrent) Storage

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

Storage ...

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) UnDownloadAllFiles

func (t *Torrent) UnDownloadAllFiles()

UnDownloadAllFiles ...

func (*Torrent) UnDownloadFile

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

UnDownloadFile ...

func (*Torrent) WaitForMetadata

func (t *Torrent) WaitForMetadata(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) *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) 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)

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) 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()

Magnet ...

func (*TorrentFile) MarshalJSON

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

MarshalJSON ...

func (*TorrentFile) Resolve

func (t *TorrentFile) Resolve() error

Resolve ...

func (*TorrentFile) StreamInfo

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

StreamInfo ...

func (*TorrentFile) UnmarshalJSON

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

UnmarshalJSON ...

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 ...

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