All Projects → cavaliercoder → Grab

cavaliercoder / Grab

Licence: bsd-3-clause
A download manager package for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Grab

Floatplane-Downloader
Project for automatically organizing and downloading Floatplane videos for plex.
Stars: ✭ 94 (-88.51%)
Mutual labels:  download-manager
su-downloader3
nodejs HTTP downloader with pause/resume support and segmented downloading
Stars: ✭ 14 (-98.29%)
Mutual labels:  download-manager
Download Manager
A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures
Stars: ✭ 482 (-41.08%)
Mutual labels:  download-manager
s3cr3t
A supercharged S3 reverse proxy
Stars: ✭ 55 (-93.28%)
Mutual labels:  download-manager
beveldm
Cross-platform download manager
Stars: ✭ 21 (-97.43%)
Mutual labels:  download-manager
Motrix Webextension
A chrome extension for the Motrix Download Manager
Stars: ✭ 253 (-69.07%)
Mutual labels:  download-manager
gropple
Server and bookmarklet to download files via youtube-dl directly from your browser. Cross platform single binary installation, web browser configurable.
Stars: ✭ 33 (-95.97%)
Mutual labels:  download-manager
Persepolis
Persepolis Download Manager is a GUI for aria2.
Stars: ✭ 5,218 (+537.9%)
Mutual labels:  download-manager
stream2segment
A Python project to download, process and visualize medium-to-massive amount of seismic waveforms and metadata
Stars: ✭ 18 (-97.8%)
Mutual labels:  download-manager
Negibox
All in one downloader 全能下载器
Stars: ✭ 335 (-59.05%)
Mutual labels:  download-manager
neurotic
Curate, visualize, annotate, and share your behavioral ephys data using Python
Stars: ✭ 24 (-97.07%)
Mutual labels:  download-manager
dl
Command-line file downloader tool
Stars: ✭ 39 (-95.23%)
Mutual labels:  download-manager
Prdownloader
PRDownloader - A file downloader library for Android with pause and resume support
Stars: ✭ 2,947 (+260.27%)
Mutual labels:  download-manager
libgen-android
This app download all the book available on (http://libgen.io/)
Stars: ✭ 21 (-97.43%)
Mutual labels:  download-manager
Downthemall
The DownThemAll! WebExtension
Stars: ✭ 512 (-37.41%)
Mutual labels:  download-manager
super-anime-downloader
A program which takes an Anime name or URL and downloads the specified range of episodes.
Stars: ✭ 26 (-96.82%)
Mutual labels:  download-manager
trailarr
A self hosted manager for movie and tv show trailers.
Stars: ✭ 13 (-98.41%)
Mutual labels:  download-manager
Motrix
A full-featured download manager.
Stars: ✭ 29,357 (+3488.88%)
Mutual labels:  download-manager
Flutter downloader
Flutter Downloader - A plugin for creating and managing download tasks. Supports iOS and Android. Maintainer: @hnvn
Stars: ✭ 546 (-33.25%)
Mutual labels:  download-manager
Turbo Download Manager
a multi-browser download manager with multi-threading support
Stars: ✭ 282 (-65.53%)
Mutual labels:  download-manager

grab

GoDoc Build Status Go Report Card

Downloading the internet, one goroutine at a time!

$ go get github.com/cavaliercoder/grab

Grab is a Go package for downloading files from the internet with the following rad features:

  • Monitor download progress concurrently
  • Auto-resume incomplete downloads
  • Guess filename from content header or URL path
  • Safely cancel downloads using context.Context
  • Validate downloads using checksums
  • Download batches of files concurrently
  • Apply rate limiters

Requires Go v1.7+

Example

The following example downloads a PDF copy of the free eBook, "An Introduction to Programming in Go" into the current working directory.

resp, err := grab.Get(".", "http://www.golang-book.com/public/pdf/gobook.pdf")
if err != nil {
	log.Fatal(err)
}

fmt.Println("Download saved to", resp.Filename)

The following, more complete example allows for more granular control and periodically prints the download progress until it is complete.

The second time you run the example, it will auto-resume the previous download and exit sooner.

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/cavaliercoder/grab"
)

func main() {
	// create client
	client := grab.NewClient()
	req, _ := grab.NewRequest(".", "http://www.golang-book.com/public/pdf/gobook.pdf")

	// start download
	fmt.Printf("Downloading %v...\n", req.URL())
	resp := client.Do(req)
	fmt.Printf("  %v\n", resp.HTTPResponse.Status)

	// start UI loop
	t := time.NewTicker(500 * time.Millisecond)
	defer t.Stop()

Loop:
	for {
		select {
		case <-t.C:
			fmt.Printf("  transferred %v / %v bytes (%.2f%%)\n",
				resp.BytesComplete(),
				resp.Size(),
				100*resp.Progress())

		case <-resp.Done:
			// download is complete
			break Loop
		}
	}

	// check for errors
	if err := resp.Err(); err != nil {
		fmt.Fprintf(os.Stderr, "Download failed: %v\n", err)
		os.Exit(1)
	}

	fmt.Printf("Download saved to ./%v \n", resp.Filename)

	// Output:
	// Downloading http://www.golang-book.com/public/pdf/gobook.pdf...
	//   200 OK
	//   transferred 42970 / 2893557 bytes (1.49%)
	//   transferred 1207474 / 2893557 bytes (41.73%)
	//   transferred 2758210 / 2893557 bytes (95.32%)
	// Download saved to ./gobook.pdf
}

Design trade-offs

The primary use case for Grab is to concurrently downloading thousands of large files from remote file repositories where the remote files are immutable. Examples include operating system package repositories or ISO libraries.

Grab aims to provide robust, sane defaults. These are usually determined using the HTTP specifications, or by mimicking the behavior of common web clients like cURL, wget and common web browsers.

Grab aims to be stateless. The only state that exists is the remote files you wish to download and the local copy which may be completed, partially completed or not yet created. The advantage to this is that the local file system is not cluttered unnecessarily with addition state files (like a .crdownload file). The disadvantage of this approach is that grab must make assumptions about the local and remote state; specifically, that they have not been modified by another program.

If the local or remote file are modified outside of grab, and you download the file again with resuming enabled, the local file will likely become corrupted. In this case, you might consider making remote files immutable, or disabling resume.

Grab aims to enable best-in-class functionality for more complex features through extensible interfaces, rather than reimplementation. For example, you can provide your own Hash algorithm to compute file checksums, or your own rate limiter implementation (with all the associated trade-offs) to rate limit downloads.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].