Giter Club home page Giter Club logo

uget's Introduction

uget (universal get)

Travis Build Status

Table of contents

  1. Introduction
  2. Getting started
  3. Installation
  4. Code examples
  5. CLI
  6. Contributing
  7. Reporting bugs

1. Introduction

This project aims at providing an API / CLI for downloading remote files, focusing mainly on premium file-hosters.

This repository holds the core project and aims to be very flexible. Check out the supported providers at the other repository

WARNING: This package is under heavy development, so documentation may fall behind and the APIs may change.

2. Getting started

2.1 Installation

It's simple! Install Go, setup your $GOPATH and run:
go install github.com/uget/uget

2.2 Library usage

It's best to check out the cli code for examples.

Downloading a multitude of links:

import "github.com/uget/uget/core"

// First, get your links from somewhere:
urls := ...
// Then, create a new downloader:
downloader := core.NewClient()
// Add those links to the downloader's queue:
waitGroup := downloader.AddURLs(urls)
// Register some callbacks:
downloader.OnDownload(func(download *core.Download) {
	// Access the File field:
	download.File.Name()
	download.File.URL()
	download.File.Length()

	// hashObject is a hash.Hash used for generating a checksum
	checksum, algorithmName, hashObject := download.File.Checksum()

	// the provider, e.g. basic / imgur.com / uploaded.net / oboom.com etc.
	// see a list of all providers at https://github.com/uget/providers
	download.File.Provider()

	// wait for download to finish:
	download.Wait()
	// and get the error if there was one:
	download.Err()

	// OR: print download status every second

	interval := 1*time.Second
	ticker := time.NewTicker(interval)
	defer ticker.Stop()

	fmt.Printf("%s: started\n", download.File.Name())
	for {
		select {
		case <-ticker.C:
			percentage := download.Progress() / download.File.Size()
			fmt.Printf("  %s: %.2f%% of %d\n", download.File.Name(), percentage, download.File.Size())
		case <-download.Waiter():
			if download.Err() != nil {
				fmt.Printf("  %s: ERROR! %v\n", download.File.Name(), download.Err())
			} else {
				fmt.Printf("  %s: DONE!\n", download.File.Name())
			}
			return
		}
	}
})
// Start client (in the background)
downloader.Start()

// Wait for the jobs provided earlier to finish
waitGroup.Wait()

// No downloads left, all jobs done.

2.3 CLI

Implemented

Get remote files:

uget get CONTAINER_SPEC...

Read meta information on remote files:

uget meta CONTAINER_SPEC...

CONTAINER_SPEC can be a plain file with a list of URLs. If option -i is passed, the arguments are interpreted as direct URLs instead.

Add an account to a provider. You will be prompted for your credentials.

uget accounts add [PROVIDER]

List your saved accounts.

uget accounts list [PROVIDER]

Not (fully) implemented yet

Start server as daemon.

uget daemon

Start server in foreground.

uget server

Push a list of files to the listening server.

uget push [OPTIONS...] CONTAINER_SPEC...

Tell the daemon to drop a container (or a file)

uget drop [ID]

Pause the daemon.

uget pause [--soft]

Continue the daemon.

uget continue

List the downloads.

uget list [CONTAINER_ID]

3. Contributing

Contributions are welcome! Fork -> Push -> Pull request.

4. Bug report / suggestions

Just create an issue! I will try to reply as soon as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.