downloader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package downloader contains the common code.

Index

Constants

This section is empty.

Variables

View Source
var DownloadHandlers = []Downloader{
	downloadCover,
	downloadAudiobook,
	downloadBook,
	downloadDemo,
	downloadPhotos,
}

DownloadHandlers list of handlers used.

Functions

func CheckRedirect

func CheckRedirect(_ *http.Request, via []*http.Request) error

CheckRedirect custom cycle redirect error.

func CheckResponse

func CheckResponse(res *http.Response) error

CheckResponse returns an error (of type *Error) if the response status code is not 2xx.

func Download

func Download(basepath string, book jd.Book) error

Download starting the download mechanism.

Types

type Downloader

type Downloader func(path string, book jd.Book) error

Downloader type for handlers.

type Error

type Error struct {
	// Code is the HTTP response status code and will always be populated.
	Code int `json:"code"`
	// Message is the server response message and is only populated when
	// explicitly referenced by the JSON server response.
	Message string `json:"message"`
	// Body is the raw response returned by the server.
	// It is often but not always JSON, depending on how the request fails.
	Body string
	// Header contains the response header fields from the server.
	Header http.Header

	Errors []ErrorItem
}

Error contains an error response from the server.

func (*Error) Error

func (e *Error) Error() string

type ErrorItem

type ErrorItem struct {
	// Reason is the typed error code. For example: "some_example".
	Reason string `json:"reason"`
	// Message is the human-readable description of the error.
	Message string `json:"message"`
}

ErrorItem is a detailed error code & message from the Google API frontend.

Jump to

Keyboard shortcuts

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