goxel

package
v0.0.0-...-0e00703 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package goxel provides the GoXel download accelerator written in Go.

The GoXel strict contains all the allowed parameters. Then the Run method needs to be called to start the downloads.

GoXel includes an Alldebrid preprocessor that tries to debrid supported links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURLSlice

func BuildURLSlice(urls []string, inputFile string) []string

BuildURLSlice builds the initial URLs list containing URLs from command line and input file

func DownloadWorker

func DownloadWorker(i int, wg *sync.WaitGroup, chunks chan download, bs int, finished chan header)

DownloadWorker is the worker functions that processes the download of one Chunk. It takes a WaitGroup to ensure all workers have finished before exiting the program. It also takes a Channel of Chunks to receive the chunks to download.

func Monitoring

func Monitoring(files []*File, done chan bool, d chan download, quiet bool)

Monitoring handles the files' termination and monitoring

func NewClient

func NewClient() (*http.Client, error)

NewClient returns a HTTP client with the requested configuration It supports HTTP and SOCKS proxies

func RebalanceChunks

func RebalanceChunks(h chan header, d chan download, files []*File)

RebalanceChunks ensures new connections have a chunk attributed to help delayed ones

Types

type AllDebridURLPreprocessor

type AllDebridURLPreprocessor struct {
	Client                 *http.Client
	Login, Password, Token string
	Initialized, UseMe     bool
	Domains                map[string]*regexp.Regexp
	API                    string
}

AllDebridURLPreprocessor implements the UrlPreprocessor interface. It handles the conversion of links after the debriding

type AllDebridUser

type AllDebridUser struct {
	Premium  bool   `json:"isPremium"`
	Username string `json:"username"`
	Email    string `json:"email"`
}

AllDebridUser represents a Alldebrid User as returned by the login call

type Chunk

type Chunk struct {
	ID, Worker              uint32
	Start, End, Done, Total uint64
}

Chunk stores a part of a file being downloaded

func (*Chunk) BuildProgress

func (c *Chunk) BuildProgress(buf []string, unit float64)

BuildProgress builds the progress display for a specific Chunk "-" means downloaded during this process " " means not yet downloaded

func (*Chunk) Write

func (c *Chunk) Write(b []byte) (int, error)

type ConsoleMonitoring

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

ConsoleMonitoring monitors the current downloads and display the speed and progress for each files

type DomainsResponse

type DomainsResponse struct {
	Success bool              `json:"success"`
	Domains map[string]string `json:"hosts"`
}

DomainsResponse represents the list of domain's regexp supported by Alldebrid

type File

type File struct {
	URL, Output, OutputWork      string
	Chunks                       []Chunk
	Finished, Valid, Initialized bool
	Error                        string
	Size, Initial                uint64
	Progress                     []string
	Mux                          sync.Mutex
	ID                           uint32
}

File stores a file to be downloaded

func (*File) BuildChunks

func (f *File) BuildChunks(wg *sync.WaitGroup, chunks chan download, nbrPerFile int)

BuildChunks builds the Chunks slice for each part of the file to be downloaded It retrieves existing metadata file in order to resume downloads. Each created chunk is sent to the channel past in parameters. The nbrPerFile parameter determines the max number of splits for each file. In case the download is being resumed, the nbrPerFile is ignored in favor of the number stored in the metadata file.

func (*File) BuildProgress

func (f *File) BuildProgress(unit float64) string

BuildProgress builds the progress display for a specific File "-" means downloaded during this process " " means not yet downloaded "+" means already downloaded during a previous process (resumed)

func (*File) ResumeChunks

func (f *File) ResumeChunks(maxConnPerFile int) bool

ResumeChunks tries to resume the current download by checking if the file exists and is valid

func (*File) UpdateStatus

func (f *File) UpdateStatus(commit bool) (float64, uint64, uint64, uint64)

UpdateStatus returns the current status of the download The first returned value is the progress percentage The second returned value is the number of active connections for this file The third returned value is the number of bytes downloaded The last returned value is the number of bytes downloaded during this session

type GoXel

type GoXel struct {
	AlldebridLogin, AlldebridPassword                                 string
	IgnoreSSLVerification, OverwriteOutputFile, Quiet, Scroll, Resume bool
	OutputDirectory, InputFile, Proxy                                 string
	MaxConnections, MaxConnectionsPerFile, BufferSize                 int
	Headers                                                           map[string]string
	URLs                                                              []string
}

GoXel structure contains all the parameters to be used for the GoXel accelerator Credentials can either be passed in command line arguments or using the following environment variables: - GOXEL_ALLDEBRID_USERNAME - GOXEL_ALLDEBRID_PASSWD

func NewGoXel

func NewGoXel() *GoXel

NewGoXel builds a GoXel instance based on the command line arguments

func (*GoXel) Run

func (g *GoXel) Run()

Run starts the downloading process

type LinkInfos

type LinkInfos struct {
	Link     string `json:"link"`
	Filename string `json:"filename"`
}

LinkInfos contains link related information as sent by Alldebrid

type LinkResponse

type LinkResponse struct {
	Success bool      `json:"success"`
	Error   int       `json:"errorCode"`
	Infos   LinkInfos `json:"infos"`
}

LinkResponse represents the answer of the link's debriding request

type LoginResponse

type LoginResponse struct {
	Success bool          `json:"success"`
	Token   string        `json:"token"`
	User    AllDebridUser `json:"user"`
	Error   int           `json:"errorCode"`
}

LoginResponse represents the Alldebrid login JSON response, it contains the authentication Token that will be used in all calls

type Message

type Message struct {
	FileID           uint32
	Content, Context string
	Type             MessageType
}

Message contains global messages to be displayed by monitoring

func NewErrorMessage

func NewErrorMessage(context string, content string) Message

NewErrorMessage builds an Error message with no related file

func NewErrorMessageForFile

func NewErrorMessageForFile(fileID uint32, context string, content string) Message

NewErrorMessageForFile builds an Error message with a related file

func NewInfoMessage

func NewInfoMessage(context string, content string) Message

NewInfoMessage builds an Info message with no related file

func NewInfoMessageForFile

func NewInfoMessageForFile(fileID uint32, context string, content string) Message

NewInfoMessageForFile builds an Info message with a related file

func NewMessageForFile

func NewMessageForFile(fileID uint32, context string, content string, t MessageType) Message

NewMessageForFile builds a standard Message

func NewWarningMessage

func NewWarningMessage(context string, content string) Message

NewWarningMessage builds a Warning message with no related file

func NewWarningMessageForFile

func NewWarningMessageForFile(fileID uint32, context string, content string) Message

NewWarningMessageForFile builds a Warning message with a related file

type MessageType

type MessageType int

MessageType identifies the severity of the message

const (
	Info MessageType = iota + 1
	Warning
	Error
)

Message Severities

func (MessageType) String

func (t MessageType) String() string

type QuietMonitoring

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

QuietMonitoring only ensures the Files are synced every Xs

type StandardURLPreprocessor

type StandardURLPreprocessor struct{}

StandardURLPreprocessor ensures the URL is correct and trims it

type URLPreprocessor

type URLPreprocessor interface {
	// contains filtered or unexported methods
}

URLPreprocessor defines the interface for the URL processors New processors can easily be added to transform input URLs for example

Jump to

Keyboard shortcuts

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