Documentation
¶
Index ¶
- Constants
- Variables
- func DebugAll(s *Service) http.Handler
- func DebugBundle(s *Service) http.Handler
- func IsWatchedFile(path string, size int64) bool
- func MatchEpisodeFilename(s, e int, isSingleSeason bool, show *tmdb.Show, episode *tmdb.Episode, ...) (index, found int)
- func SetWatchedFile(path string, size int64, watched bool)
- func TrimChoices(choices []*CandidateFile)
- func URLForHTTP(pattern string, args ...interface{}) string
- func URLForXBMC(pattern string, args ...interface{}) string
- func URLQuery(route string, query ...string) string
- type Action
- type Alert
- type AnnounceRequest
- type AnnounceResponse
- type Bitfield
- type CandidateFile
- type ConnectionResponse
- type File
- type MemoryFile
- func (mf *MemoryFile) Close() (err error)
- func (mf *MemoryFile) IsDir() bool
- func (mf *MemoryFile) ModTime() time.Time
- func (mf *MemoryFile) Mode() os.FileMode
- func (mf *MemoryFile) Name() string
- func (mf *MemoryFile) Read(b []byte) (n int, err error)
- func (mf *MemoryFile) ReadPiece(b []byte, piece int, pieceOffset int) (n int, err error)
- func (mf *MemoryFile) Readdir(count int) (ret []os.FileInfo, err error)
- func (mf *MemoryFile) Seek(off int64, whence int) (ret int64, err error)
- func (mf *MemoryFile) Size() int64
- func (mf *MemoryFile) Stat() (ret os.FileInfo, err error)
- func (mf *MemoryFile) Sys() interface{}
- type NextEpisode
- type Peer
- type PieceRange
- type Player
- func (btp *Player) Buffer() error
- func (btp *Player) Close()
- func (btp *Player) DownloadSubtitles()
- func (btp *Player) FetchStoredResume()
- func (btp *Player) GetIdent()
- func (btp *Player) GetTorrent() *Torrent
- func (btp *Player) HasChosenFile() bool
- func (btp *Player) InitAudio()
- func (btp *Player) InitSubtitles()
- func (btp *Player) IsWatched() bool
- func (btp *Player) Params() *PlayerParams
- func (btp *Player) PlayURL() string
- func (btp *Player) SaveStoredResume()
- func (btp *Player) SetSubtitles()
- func (btp *Player) SetTorrent(t *Torrent)
- func (btp *Player) UpdateWatched()
- type PlayerParams
- type Queue
- type ScrapeResponseEntry
- type Service
- func (s *Service) AddTorrent(uri string, paused bool) (*Torrent, error)
- func (s *Service) Alerts() (<-chan *Alert, chan<- interface{})
- func (s *Service) AttachPlayer(p *Player)
- func (s *Service) ClientInfo(_w io.Writer)
- func (s *Service) Close(isShutdown bool)
- func (s *Service) CloseSession()
- func (s *Service) DetachPlayer(p *Player)
- func (s *Service) GetActivePlayer() *Player
- func (s *Service) GetBufferSize() int64
- func (s *Service) GetListenIP(network string) string
- func (s *Service) GetMemorySize() int64
- func (s *Service) GetMemoryStats() (int64, int64)
- func (s *Service) GetPlayer(kodiID int, tmdbID int) *Player
- func (s *Service) GetSeedTime() int64
- func (s *Service) GetStorageType() int
- func (s *Service) GetTorrentByHash(hash string) *Torrent
- func (s *Service) GetTorrents() []*Torrent
- func (s *Service) HasTorrentByEpisode(tmdbID int, season, episode int) *Torrent
- func (s *Service) HasTorrentByFakeID(query string) *Torrent
- func (s *Service) HasTorrentByID(tmdbID int) *Torrent
- func (s *Service) HasTorrentByName(query string) *Torrent
- func (s *Service) HasTorrentByQuery(query string) *Torrent
- func (s *Service) HasTorrentBySeason(tmdbID int, season int) *Torrent
- func (s *Service) IsMemoryStorage() bool
- func (s *Service) PlayerSeek()
- func (s *Service) PlayerStop()
- func (s *Service) Reconfigure()
- func (s *Service) RemoveTorrent(t *Torrent, forceDrop, forceDelete, isWatched bool) bool
- func (s *Service) RestoreLimits()
- func (s *Service) SetBufferingLimits()
- func (s *Service) SetDownloadLimit(i int)
- func (s *Service) SetUploadLimit(i int)
- func (s *Service) StopNextFiles()
- type Torrent
- func (t *Torrent) AdjustMemorySize(ms int64)
- func (t *Torrent) Buffer(file *File, isStartup bool)
- func (t *Torrent) ChooseFile(btp *Player) (*File, int, error)
- func (t *Torrent) ClearDeadlines()
- func (t *Torrent) CloseReaders()
- func (t *Torrent) DownloadAllFiles()
- func (t *Torrent) DownloadFile(addFile *File)
- func (t *Torrent) Drop(removeFiles bool)
- func (t *Torrent) FetchDBItem() *database.BTItem
- func (t *Torrent) GetAddedTime() time.Time
- func (t *Torrent) GetBufferProgress() float64
- func (t *Torrent) GetCandidateFiles(btp *Player) ([]*CandidateFile, int, error)
- func (t *Torrent) GetConnections() (int, int, int, int)
- func (t *Torrent) GetDBItem() *database.BTItem
- func (t *Torrent) GetFileByIndex(q int) *File
- func (t *Torrent) GetFileByPath(q string) *File
- func (t *Torrent) GetFilePieces(files lt.FileStorage, idx int) (ret PieceRange)
- func (t *Torrent) GetFiles() []*File
- func (t *Torrent) GetHandle() lt.TorrentHandle
- func (t *Torrent) GetHumanizedSpeeds() (down, up string)
- func (t *Torrent) GetMetadata() []byte
- func (t *Torrent) GetNextEpisodeFile(season, episode int) *File
- func (t *Torrent) GetPaused() bool
- func (t *Torrent) GetPlayURL(fileIndex string) string
- func (t *Torrent) GetProgress() float64
- func (t *Torrent) GetReadaheadSize() (ret int64)
- func (t *Torrent) GetRealProgress() float64
- func (t *Torrent) GetSpeeds() (down, up int)
- func (t *Torrent) GetState() int
- func (t *Torrent) GetStateString() string
- func (t *Torrent) GetStatus() lt.TorrentStatus
- func (t *Torrent) GotInfo() <-chan struct{}
- func (t *Torrent) HasAvailableFiles() bool
- func (t *Torrent) HasMetadata() bool
- func (t *Torrent) InfoHash() string
- func (t *Torrent) Length() int64
- func (t *Torrent) MakeFiles()
- func (t *Torrent) Name() string
- func (t *Torrent) Pause()
- func (t *Torrent) PrioritizePiece(piece int)
- func (t *Torrent) PrioritizePieces()
- func (t *Torrent) ReadersReadaheadSum() int64
- func (t *Torrent) ResetReaders()
- func (t *Torrent) Resume()
- func (t *Torrent) SaveDBFiles()
- func (t *Torrent) SaveMetainfo(path string) error
- func (t *Torrent) Storage() lt.StorageInterface
- func (t *Torrent) Title() string
- func (t *Torrent) UnDownloadAllFiles()
- func (t *Torrent) UnDownloadFile(addFile *File) bool
- func (t *Torrent) WaitForMetadata(infoHash string) (err error)
- func (t *Torrent) Watch()
- type TorrentFS
- type TorrentFSEntry
- func (tf *TorrentFSEntry) Close() error
- func (tf *TorrentFSEntry) IsActive() bool
- func (tf *TorrentFSEntry) IsIdle() bool
- func (tf *TorrentFSEntry) Pos() (int64, error)
- func (tf *TorrentFSEntry) Read(data []byte) (n int, err error)
- func (tf *TorrentFSEntry) Readahead() int64
- func (tf *TorrentFSEntry) ReaderPiecesRange() (ret PieceRange)
- func (tf *TorrentFSEntry) Seek(offset int64, whence int) (int64, error)
- func (tf *TorrentFSEntry) SetActive(is bool)
- type TorrentFile
- func (t *TorrentFile) Download() ([]byte, error)
- func (t *TorrentFile) IsMagnet() bool
- func (t *TorrentFile) IsValidMagnet() (err error)
- func (t *TorrentFile) LoadFromBytes(in []byte) error
- func (t *TorrentFile) Magnet()
- func (t *TorrentFile) MarshalJSON() ([]byte, error)
- func (t *TorrentFile) Resolve() error
- func (t *TorrentFile) StreamInfo() *xbmc.StreamInfo
- func (t *TorrentFile) UnmarshalJSON(b []byte) error
- type TorrentFileRaw
- type Tracker
- type TrackerRequest
- type TrackerResponse
Constants ¶
const ( // ResolutionUnknown ... ResolutionUnknown = iota // Resolution240p ... Resolution240p // Resolution480p ... Resolution480p // Resolution720p ... Resolution720p // Resolution1080p ... Resolution1080p // Resolution2K ... Resolution2K // Resolution4k ... Resolution4k )
const ( // RipUnknown ... RipUnknown = iota // RipCam ... RipCam // RipTS ... RipTS // RipTC ... RipTC // RipScr ... RipScr // RipDVDScr ... RipDVDScr // RipDVD ... RipDVD // RipHDTV ... RipHDTV // RipWeb ... RipWeb // RipBluRay ... RipBluRay )
const ( // RatingUnkown ... RatingUnkown = iota // RatingProper ... RatingProper // RatingNuked ... RatingNuked )
const ( // CodecUnknown ... CodecUnknown = iota // CodecXVid ... CodecXVid // CodecH264 ... CodecH264 // CodecH265 ... CodecH265 // CodecMp3 ... CodecMp3 // CodecAAC ... CodecAAC // CodecAC3 ... CodecAC3 // CodecDTS ... CodecDTS // CodecDTSHD ... CodecDTSHD // CodecDTSHDMA ... CodecDTSHDMA )
const ( // StorageFile ... StorageFile int = iota // StorageMemory ... StorageMemory )
const ( // StatusQueued ... StatusQueued = iota // StatusChecking ... StatusChecking // StatusFinding ... StatusFinding // StatusDownloading ... StatusDownloading // StatusFinished ... StatusFinished // StatusSeeding ... StatusSeeding // StatusAllocating ... StatusAllocating // StatusStalled ... StatusStalled // StatusPaused ... StatusPaused // StatusBuffering ... StatusBuffering // StatusPlaying ... StatusPlaying )
const ( // Remove ... Remove = iota // Active ... Active )
const ( // ProxyTypeNone ... ProxyTypeNone = iota // ProxyTypeSocks4 ... ProxyTypeSocks4 // ProxyTypeSocks5 ... ProxyTypeSocks5 // ProxyTypeSocks5Password ... ProxyTypeSocks5Password // ProxyTypeSocksHTTP ... ProxyTypeSocksHTTP // ProxyTypeSocksHTTPPassword ... ProxyTypeSocksHTTPPassword // ProxyTypeI2PSAM ... ProxyTypeI2PSAM )
Variables ¶
var ( // Resolutions ... Resolutions = []string{"", "240p", "480p", "720p", "1080p", "2K", "4K"} // Colors ... Colors = []string{"", "FFFC3401", "FFA56F01", "FF539A02", "FF0166FC", "FFF15052", "FF6BB9EC"} )
var ( // Codecs ... Codecs = []string{"", "Xvid", "H.264", "H.265", "MP3", "AAC", "AC3", "DTS", "DTS HD", "DTS HD MA"} )
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 ...
var ( // Rips ... Rips = []string{"", "Cam", "TeleSync", "TeleCine", "Screener", "DVD Screener", "DVDRip", "HDTV", "WebDL", "Blu-Ray"} )
var StatusStrings = []string{
"Queued",
"Checking",
"Finding",
"Downloading",
"Finished",
"Seeding",
"Allocating",
"Stalled",
"Paused",
"Buffering",
"Playing",
}
StatusStrings ...
var ( // Storages ... Storages = []string{ "File", "Memory", } )
Functions ¶
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 TrimChoices ¶
func TrimChoices(choices []*CandidateFile)
TrimChoices clears redundant folder names from files list and sorts remaining records.
Types ¶
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 ¶
AnnounceResponse ...
type CandidateFile ¶
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) Readdir ¶
func (mf *MemoryFile) Readdir(count int) (ret []os.FileInfo, err error)
Readdir ...
type NextEpisode ¶
type NextEpisode struct {
// contains filtered or unexported fields
}
NextEpisode ...
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player ...
func (*Player) GetIdent ¶
func (btp *Player) GetIdent()
GetIdent tries to find playing item in Kodi library
func (*Player) Params ¶
func (btp *Player) Params() *PlayerParams
Params returns Params for external use
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 (*Queue) Clean ¶
func (q *Queue) Clean()
Clean would cleanup torrents list, should be used in case of a service reload
func (*Queue) FindByHash ¶
FindByHash checks if torrent with infohash is in the queue
type ScrapeResponseEntry ¶
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 (*Service) AddTorrent ¶
AddTorrent ...
func (*Service) AttachPlayer ¶
AttachPlayer adds Player instance to service
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 ¶
DetachPlayer removes Player instance
func (*Service) GetActivePlayer ¶
GetActivePlayer searches for player that is Playing anything
func (*Service) GetListenIP ¶
GetListenIP returns calculated IP for TCP/TCP6
func (*Service) GetMemoryStats ¶
GetMemoryStats returns total and free memory sizes for this OS
func (*Service) GetTorrentByHash ¶
GetTorrentByHash ...
func (*Service) GetTorrents ¶
GetTorrents return all active torrents
func (*Service) HasTorrentByEpisode ¶
HasTorrentByEpisode checks whether there is active torrent for queried episode
func (*Service) HasTorrentByFakeID ¶
HasTorrentByFakeID checks whether there is active torrent with fake id
func (*Service) HasTorrentByID ¶
HasTorrentByID checks whether there is active torrent for queried tmdb id
func (*Service) HasTorrentByName ¶
HasTorrentByName checks whether there is active torrent for queried name
func (*Service) HasTorrentByQuery ¶
HasTorrentByQuery checks whether there is active torrent with searches query
func (*Service) HasTorrentBySeason ¶
HasTorrentBySeason checks whether there is active torrent for queried season
func (*Service) IsMemoryStorage ¶
IsMemoryStorage is a shortcut for checking whether we run memory storage
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 ¶
RemoveTorrent ...
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 ¶
AdjustMemorySize ...
func (*Torrent) Buffer ¶
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 ¶
ChooseFile opens file selector if not provided with Player, otherwise tries to detect what to open.
func (*Torrent) GetBufferProgress ¶
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 ¶
GetConnections returns connected and overall number of peers
func (*Torrent) GetFilePieces ¶
func (t *Torrent) GetFilePieces(files lt.FileStorage, idx int) (ret PieceRange)
GetFilePieces ...
func (*Torrent) GetHumanizedSpeeds ¶
GetHumanizedSpeeds returns humanize download and upload speeds
func (*Torrent) GetNextEpisodeFile ¶
GetNextEpisodeFile ...
func (*Torrent) GetPlayURL ¶
GetPlayURL returns url ready for Kodi
func (*Torrent) GetReadaheadSize ¶
GetReadaheadSize ...
func (*Torrent) GetRealProgress ¶
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) HasAvailableFiles ¶
HasAvailableFiles ...
func (*Torrent) ReadersReadaheadSum ¶
ReadersReadaheadSum ...
func (*Torrent) Title ¶
Title returns name of a torrent, or, if present, how it looked in plugin that found it.
func (*Torrent) UnDownloadFile ¶
UnDownloadFile ...
func (*Torrent) WaitForMetadata ¶
WaitForMetadata waits for getting torrent information or cancels if torrent is closed
type TorrentFSEntry ¶
TorrentFSEntry ...
func NewTorrentFSEntry ¶
func NewTorrentFSEntry(file http.File, tfs *TorrentFS, t *Torrent, f *File, name string) (*TorrentFSEntry, error)
NewTorrentFSEntry ...
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 ...
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 (*TorrentFile) Download ¶
func (t *TorrentFile) Download() ([]byte, error)
Download takes care about torrent's URI and downloads or reads cached file
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) MarshalJSON ¶
func (t *TorrentFile) MarshalJSON() ([]byte, error)
MarshalJSON ...
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 ¶
Tracker ...
func (*Tracker) Scrape ¶
func (tracker *Tracker) Scrape(torrents []*TorrentFile) []ScrapeResponseEntry
Scrape ...
type TrackerRequest ¶
TrackerRequest ...
type TrackerResponse ¶
TrackerResponse ...