arias

package module
v0.0.0-...-6db7c30 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 29 Imported by: 1

README

Arias

Build Status Documentation

Arias is a media downloader and uploader. It uses aria2 to download files and can upload them to several places.

API

Something something documentation is very hard

Documentation

Index

Constants

View Source
const Version = "0.1.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServerAddr string
	Aria2Addr  string

	StorageType string

	DefaultBucket string
	// AllowBucketOverride specifies whether the requester can override the bucket to upload to
	AllowBucketOverride bool

	// AllowNoName specifies whether the requester may omit the name from the request.
	// Arias would use the name of the downloaded file in that case
	AllowNoName bool
}

func LoadConfig

func LoadConfig(configFile string) (c Config, err error)

func (*Config) Check

func (c *Config) Check() error

type DownloadRequest

type DownloadRequest struct {
	Url    string `schema:"url"`
	Bucket string `schema:"bucket"`
	Name   string `schema:"name"`

	CallbackUrl string `schema:"callback"`
}

func (*DownloadRequest) Check

func (req *DownloadRequest) Check() error

func (*DownloadRequest) UseConfig

func (req *DownloadRequest) UseConfig(c *Config) error

type DownloadResponse

type DownloadResponse struct {
	Id string `json:"id"`
}

type DownloadTask

type DownloadTask interface {
	Task
	Download() error
	Upload() error
}

func NewDownloadTask

func NewDownloadTask(server *Server, req DownloadRequest) DownloadTask

type Server

type Server struct {
	Router     chi.Router
	HttpClient *http.Client
	Config     Config

	AriaClient aria2.Client
	Storage    Storage
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config Config) (s Server, err error)

func (*Server) GoSendCallback

func (s *Server) GoSendCallback(url string, data interface{})

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) PerformTask

func (s *Server) PerformTask(task Task)

func (*Server) SendCallback

func (s *Server) SendCallback(url string, data interface{}) (resp *http.Response, err error)

type Storage

type Storage interface {
	Upload(ctx context.Context, f io.ReadSeeker, options UploadOptions) (UploadOutput, error)
}

func NewGoogleCloudStorage

func NewGoogleCloudStorage(opts ...option.ClientOption) (s Storage, err error)

func NewS3Storage

func NewS3Storage(opts ...*aws.Config) (s Storage, err error)

func NewStorageFromType

func NewStorageFromType(storageType string) (s Storage, err error)

type Task

type Task interface {
	GetId() uuid.UUID
	GetStatus() *TaskStatus
	Perform() error
}

type TaskStatus

type TaskStatus struct {
	Id      string      `json:"id"`
	Running bool        `json:"running"`
	State   string      `json:"state"`
	Result  interface{} `json:"result,omitempty"`
	Err     interface{} `json:"error,omitempty"`
}

func NewTaskStatus

func NewTaskStatus(id string) *TaskStatus

func (*TaskStatus) Done

func (status *TaskStatus) Done(res interface{})

func (*TaskStatus) EnterState

func (status *TaskStatus) EnterState(state string)

func (*TaskStatus) Error

func (status *TaskStatus) Error(err error)

func (*TaskStatus) Start

func (status *TaskStatus) Start()

type UploadOptions

type UploadOptions struct {
	Bucket      string
	Filename    string
	ContentType string
	// ForceGZip
	ForceGZip bool
}

type UploadOutput

type UploadOutput struct {
	Bucket   string `json:"bucket"`
	Filename string `json:"filename"`
}

Directories

Path Synopsis
aria2 is a go library to communicate with the aria2 rpc interface.
aria2 is a go library to communicate with the aria2 rpc interface.
rpc
cmd

Jump to

Keyboard shortcuts

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