dlengine

package module
v0.0.0-...-0737209 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: GPL-3.0 Imports: 27 Imported by: 0

README

dlengine

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Set current Directory as default RunDir
	DefaultRunDir = "dl"
)
View Source
var Magrx = regexp.MustCompile("^magnet:\\?xt=urn:[a-zA-Z0-9]+:[a-zA-Z0-9]{32,40}")

Functions

This section is empty.

Types

type Config

type Config struct {
	// Directories
	DownloadDir string // Download Directory
	DataDir     string // Directory to Store Data
	CacheDir    string // Cache Directory

	// Engine Debugging
	EngineDebug   bool // Enables Engine Debugging
	MuteEngineLog bool // Mutes Engine Log

	AutoStart bool // Enables Autostart

	// Header Obfuscation
	ObfsPreferred        bool // Prefer Obfs
	ObfsRequirePreferred bool // Prefer Obfs to be required

	// Disable
	DisableTrackers         bool // Disable Trackers
	DisableIPv6             bool // Disable Ipv6
	DisableIPv4             bool // Disable Ipv4
	DisableDHT              bool // Disable DHT
	DisableAggressiveUpload bool //Disable AggressiveUpload

	EnableUpload  bool    // Enable Upload Support
	EnableSeeding bool    // Enable Seeding of Torrents
	IncomingPort  int     // Incoming Port of Torrent Engine
	SeedRatio     float32 // Seed Ratio of Torrent

	// Rate of Load
	UploadRate   string // Rate of Upload of Torrent
	DownloadRate string // Rate of Download of Torrent

	// Torrent Trackers
	TrackerListURL    string // URL to List of Torrent Trackers
	AlwaysAddTrackers bool   // Whether Trackers must be added

	// URL for HTTP proxy
	ProxyURL  string // Defines Proxy for HTTP requests
	UserAgent string // Defines User Agent for HTTP requests
}

Configuration Structure of dlengine

func DefConfig

func DefConfig() Config

Returns Sane Config

type Engine

type Engine struct {
	sync.RWMutex // TS and Torc has race conditions

	// Clients
	Torc *torrent.Client // Torrent Client
	Grab *grab.Client    // Grab Client

	// Each Engine has it's own Configuration
	Config Config

	// Grab Engine Specifics
	Jar                http.CookieJar // Jar of Cookies
	MaxActiveDownloads int            // Set Maximum Active Downloads

	GS map[string]*Grequest
	TS map[string]*Torrent

	BTtrackers []string // Slice of String Containing Trackers
	// contains filtered or unexported fields
}

Defines dlengine Engine

func NewEngine

func NewEngine() *Engine

Returns the pointer to the Engine

func (*Engine) AddGrequest

func (e *Engine) AddGrequest(r *Grequest) error

Add New Download Grequest

func (*Engine) Configure

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

Configure the Engine

func (*Engine) DeleteTorrent

func (e *Engine) DeleteTorrent(infohash string) error

Delete the torrent

func (*Engine) GTaskRoutine

func (e *Engine) GTaskRoutine()

Starts New Grab Downloads if they have been Queued Clean Completed/Cancelled Downloads

func (*Engine) Gdl

func (e *Engine) Gdl(url string) error

func (*Engine) GetConfig

func (e *Engine) GetConfig() Config

Confige method returns the config of the Engine

func (*Engine) GetGdl

func (e *Engine) GetGdl() map[string]*Grequest

Get Running Download Tasks

func (*Engine) GetTorrent

func (e *Engine) GetTorrent(infohash string) (*Torrent, error)

Get the torrent from infohash

func (*Engine) IsConfigred

func (e *Engine) IsConfigred() bool

Checks whether Engine is Configured

func (*Engine) NewMagnet

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

NewMagnet -> *Torrent -> addTorrentTask

func (*Engine) NewTorrentByFilePath

func (e *Engine) NewTorrentByFilePath(path string) error

NewTorrentByFilePath -> NewTorrentBySpec

func (*Engine) NewTorrentBySpec

func (e *Engine) NewTorrentBySpec(spec *torrent.TorrentSpec) error

NewTorrentBySpec -> *Torrent -> addTorrentTask

func (*Engine) SetConfig

func (e *Engine) SetConfig(c Config)

SetConfig method sets the config of the Engine

func (*Engine) Start

func (e *Engine) Start()

Starts the Engine. Run this in another Goroutine

func (*Engine) StartFile

func (e *Engine) StartFile(infohash, filepath string) error

Start the File

func (*Engine) StartGrequest

func (e *Engine) StartGrequest(r *Grequest)

Start Grequest and clean tasks when complete. Run this in another goroutine

func (*Engine) StartTorrent

func (e *Engine) StartTorrent(infohash string) error

Start the Torrent

func (*Engine) StopFile

func (e *Engine) StopFile(infohash, filepath string) error

Stop the File

func (*Engine) StopTorrent

func (e *Engine) StopTorrent(infohash string) error

Stop the Torrent

func (*Engine) TTaskRoutine

func (e *Engine) TTaskRoutine()

Syncs anacrolix/torrent to Engine's struct Stops Task on Reaching ratio

func (*Engine) UpdateTrackers

func (e *Engine) UpdateTrackers() error

Update the trackers

func (*Engine) UpsertTorrent

func (e *Engine) UpsertTorrent(tt *torrent.Torrent) *Torrent

Upserts the Torrent

func (*Engine) WriteTStat

func (e *Engine) WriteTStat(w io.Writer)

Write Torrent Engine Status

type File

type File struct {
	//anacrolix/torrent
	Path      string
	Size      int64
	Completed int64
	Done      bool
	// dl engine
	Started bool
	Percent float32
	F       *torrent.File
}

Define structure for Files of Torrent

type Grequest

type Grequest struct {
	URL           string
	Cookies       []http.Cookie
	ForceDownload bool
	Status        Status
	Priority      Priority
	FilePath      string
	Filename      string
	Subdir        string
	Response      *grab.Response
	Error         error
	CompletedDate time.Time
}

type Priority

type Priority uint8
const (
	Highest Priority = iota
	High
	Medium
	Low
)

type Status

type Status uint8
const (
	Queued Status = iota
	Complete
	Stopped
	Paused
	Downloading
	Error
	Canceled
)

type Torrent

type Torrent struct {
	// put at first postition to prevent memorty align issues.
	Stats torrent.TorrentStats

	//anacrolix/torrent
	InfoHash   string
	Name       string
	Magnet     string
	Loaded     bool
	Downloaded int64
	Uploaded   int64
	Size       int64
	Files      []*File

	//remdl torrent engine
	Started      bool
	Done         bool
	IsDoneReady  bool
	Percent      float32
	DownloadRate float32
	UploadRate   float32
	SeedRatio    float32
	AddedAt      time.Time
	StartedAt    time.Time
	T            *torrent.Torrent
	// contains filtered or unexported fields
}

Structure of Torrent

func (*Torrent) Update

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

Update retrive info from torrent.Torrent

Jump to

Keyboard shortcuts

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