pget

package module
v0.0.0-...-564e383 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: GPL-3.0 Imports: 18 Imported by: 0

README

Pget - parallel file download client

Build Status Coverage Status Go Report Card GitHub release License (GPL version 3)

Description

Download using a parallel requests

asciicast

Installation

Homebrew
brew tap Code-Hex/pget
brew install pget
go get

Install

$ go get github.com/Code-Hex/pget/cmd/pget

Update

$ go get -u github.com/Code-Hex/pget/cmd/pget

Synopsis

% pget -p 6 URL

Options

  Options:
  -h,  --help                      print usage and exit
  -v,  --version                   display the version of pget and exit
  -p,  --procs <num>               split ratio to download file
  -o,  --output <PATH|FILENAME>    output file to PATH or FILENAME
  -t,  --timeout <seconds>         timeout of checking request in seconds
  --check-update                   check if there is update available
  --trace                          display detail error messages

Pget vs Wget

URL: http://ubuntutym2.u-toyama.ac.jp/ubuntu/16.04/ubuntu-16.04-desktop-amd64.iso

Using

time wget http://ubuntutym2.u-toyama.ac.jp/ubuntu/16.04/ubuntu-16.04-desktop-amd64.iso
time pget -p 6 http://ubuntutym2.u-toyama.ac.jp/ubuntu/16.04/ubuntu-16.04-desktop-amd64.iso

Results

wget   3.92s user 23.52s system 3% cpu 13:35.24 total
pget -p 6   10.54s user 34.52s system 25% cpu 2:56.93 total

Binary

You can download from here

Author

codehex

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ch

type Ch struct {
	Err  chan error
	Done chan bool
}

Ch struct for request

func (*Ch) Close

func (ch *Ch) Close()

Close method will close channel in Ch struct

func (*Ch) Listen

func (ch *Ch) Listen(ctx context.Context, cancelAll context.CancelFunc, totalActiveProcs int) (e error)

Listen method wait all channels

type Data

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

Data struct has file of relational data

func (*Data) BindwithFiles

func (d *Data) BindwithFiles(procs int) error

BindwithFiles function for file binding after split download

func (Data) DirName

func (d Data) DirName() string

DirName get from Data structs member

func (Data) FileName

func (d Data) FileName() string

FileName get from Data structs member

func (Data) FileSize

func (d Data) FileSize() uint64

FileSize get from Data structs member

func (Data) IsFree

func (d Data) IsFree(split uint64) error

IsFree is check your disk space for size needed to download

func (*Data) MakeRange

func (d *Data) MakeRange(i, split, procs uint64) Range

MakeRange will return Range struct to download function

func (Data) ProgressBar

func (d Data) ProgressBar(ctx context.Context, ch *Ch)

ProgressBar is to show progressbar

func (*Data) SetDirName

func (d *Data) SetDirName(path, filename string, procs int)

SetDirName set to Data structs member

func (*Data) SetFileName

func (d *Data) SetFileName(output string)

SetFileName set to Data structs member

func (*Data) SetFileSize

func (d *Data) SetFileSize(size uint64)

SetFileSize set to Data structs member

func (Data) SplitFilePath

func (d Data) SplitFilePath(output string) (string, string, error)

SplitFilePath will return filename and path from input

func (*Data) URLFileName

func (d *Data) URLFileName(url string)

URLFileName set to Data structs member using url

type Options

type Options struct {
	Help    bool   `short:"h" long:"help" description:"print usage and exit"`
	Version bool   `short:"v" long:"version" description:"display the version of pget and exit"`
	Procs   int    `short:"p" long:"procs" description:"split ratio to download file"`
	Output  string `short:"o" long:"output" description:"output file to PATH or FILENAME"`
	Timeout int    `short:"t" long:"timeout" description:"timeout of checking request in seconds"`
	Update  bool   `long:"check-update" description:"check if there is update available"`
	Trace   bool   `long:"trace" description:"display detail error messages"`
}

Options struct for parse command line arguments

type Pget

type Pget struct {
	Trace bool
	Utils
	// contains filtered or unexported fields
}

Pget structs

func New

func New() *Pget

New for pget package

func (*Pget) Checking

func (p *Pget) Checking() error

Checking is check to can request

func (Pget) ErrTop

func (pget Pget) ErrTop(err error) error

ErrTop get important message from wrapped error message

func (Pget) MakeResponse

func (p Pget) MakeResponse(ctx context.Context, low, high, worker uint64) (*http.Response, error)

MakeResponse return *http.Response include context and range header

func (*Pget) Run

func (pget *Pget) Run() error

Run execute methods in pget package

type Range

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

Range struct for range access

type Utils

type Utils interface {
	SplitFilePath(string) (string, string, error)
	ProgressBar(context.Context, *Ch)
	BindwithFiles(int) error
	IsFree(uint64) error
	MakeRange(uint64, uint64, uint64) Range

	// like setter
	SetFileName(string)
	URLFileName(string)
	SetDirName(string, string, int)
	SetFileSize(uint64)

	// like getter
	FileName() string
	FileSize() uint64
	DirName() string
}

Utils interface indicate function

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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