pget

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 19 Imported by: 8

README

Pget - The fastest file download client

.github/workflows/main.yaml codecov Go Report Card GitHub release MIT License

Description

Download using a parallel requests

asciicast

Installation

Homebrew
brew update
brew install Code-Hex/tap/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 
% pget -p 6 MIRROR1 MIRROR2 MIRROR3

If you have created such as this file

cat list.txt
MIRROR1
MIRROR2
MIRROR3

You can do this

cat list.txt | pget -p 6

Options

  Options:
  -h,  --help                   print usage and exit
  -p,  --procs <num>            split ratio to download file
  -o,  --output <filename>      output file to <filename>
  -t,  --timeout <seconds>      timeout of checking request in seconds
  -u,  --user-agent <agent>     identify as <agent>
  -r,  --referer <referer>      identify as <referer>
  --check-update                check if there is update available
  --trace                       display detail error messages

Pget vs Wget

URL: https://mirror.internet.asn.au/pub/ubuntu/releases/21.10/ubuntu-21.10-desktop-amd64.iso

Using

time wget https://mirror.internet.asn.au/pub/ubuntu/releases/21.10/ubuntu-21.10-desktop-amd64.iso
time pget -p 6 https://mirror.internet.asn.au/pub/ubuntu/releases/21.10/ubuntu-21.10-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

Disclaimer

This program comes with no warranty. You must use this program at your own risk.

Author

codehex

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, c *DownloadConfig, opts ...DownloadOption) error

Types

type CheckConfig

type CheckConfig struct {
	URLs           []string
	Timeout        time.Duration
	DisableLogging bool
}

CheckConfig is a configuration to check download target.

type DownloadConfig

type DownloadConfig struct {
	Filename      string
	Dirname       string
	ContentLength int64
	Procs         int
	URLs          []string
	// contains filtered or unexported fields
}

type DownloadOption

type DownloadOption func(c *DownloadConfig)

func WithReferer

func WithReferer(referer string) DownloadOption

func WithUserAgent

func WithUserAgent(ua string) DownloadOption

type Options

type Options struct {
	Help      bool   `short:"h" long:"help"`
	Procs     int    `short:"p" long:"procs"`
	Output    string `short:"o" long:"output"`
	Timeout   int    `short:"t" long:"timeout"`
	UserAgent string `short:"u" long:"user-agent"`
	Referer   string `short:"r" long:"referer"`
	Update    bool   `long:"check-update"`
	Trace     bool   `long:"trace"`
}

Options struct for parse command line arguments

type Pget

type Pget struct {
	Trace  bool
	Output string
	Procs  int
	URLs   []string
	// contains filtered or unexported fields
}

Pget structs

func New

func New() *Pget

New for pget package

func (*Pget) Ready

func (pget *Pget) Ready(version string, args []string) error

Ready method define the variables required to Download.

func (*Pget) Run

func (pget *Pget) Run(ctx context.Context, version string, args []string) error

Run execute methods in pget package

type Range

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

Range struct for range access

func (Range) BytesRange

func (r Range) BytesRange() string

type Target

type Target struct {
	Filename      string
	ContentLength int64
	URLs          []string
}

Target represensts download target.

func Check

func Check(ctx context.Context, c *CheckConfig) (*Target, error)

Check checks be able to download from targets

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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