utils

package
v0.0.0-...-e2bc47a Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

The utils package contains methods used by the tool. All these methods are not needed if gphotosuploader is used as a library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFileImageOrVideo

func IsFileImageOrVideo(file *os.File) (bool, error)

Check if the file has a image or video mime. This function read the first 512 bytes of the file. Before and after the reading of the file offset is reset

func IsImageOrVideo

func IsImageOrVideo(fileName string) (bool, error)

Check if the file at the given path is an image or a video

func SeleniumToGoCookie

func SeleniumToGoCookie(seleniumCookie selenium.Cookie) *http.Cookie

utility to convert a selenium cookie to a go http.Cookie

func SeleniumToGoCookies

func SeleniumToGoCookies(seleniumCookies []selenium.Cookie) []*http.Cookie

Utility to convert selenium cookies slice to go http.Cookie slice

func StartWebDriverCookieCredentialsWizard

func StartWebDriverCookieCredentialsWizard() (*auth.CookieCredentials, error)

Start a wizard that open a browser to let the user authenticate and return an auth.Credentials implementation

Types

type ConcurrentUploader

type ConcurrentUploader struct {
	CompletedUploads chan string
	IgnoredUploads   chan string
	Errors           chan error
	// contains filtered or unexported fields
}

Simple client used to implement the tool that can upload multiple photos or videos at once

func NewUploader

func NewUploader(credentials auth.CookieCredentials, albumId string, maxConcurrentUploads int) (*ConcurrentUploader, error)

Creates a new ConcurrentUploader using the specified credentials. The second argument is the id of the album in which images are going to be added when uploaded. Use an empty string if you don't want to move the images in to a specific album. The third argument is the maximum number of concurrent uploads (which must not be 0).

func (*ConcurrentUploader) AddUploadedFiles

func (u *ConcurrentUploader) AddUploadedFiles(files ...string)

Add files to the list of already uploaded files

func (*ConcurrentUploader) EnqueueUpload

func (u *ConcurrentUploader) EnqueueUpload(filePath string) error

Enqueue a new upload. You must not call this method while waiting for some uploads to finish (The method return an error if you try to do it). Due to the fact that this method is asynchronous, if nil is return it doesn't mean the the upload was completed: for that use the Errors and CompletedUploads channels

func (*ConcurrentUploader) WaitUploadsCompleted

func (u *ConcurrentUploader) WaitUploadsCompleted()

Blocks this goroutine until all the upload are completed. You can not add uploads when a goroutine call this method

type DirectoriesToWatch

type DirectoriesToWatch []string

Slice of names of directories to watch

func (*DirectoriesToWatch) Set

func (a *DirectoriesToWatch) Set(name string) error

func (*DirectoriesToWatch) String

func (a *DirectoriesToWatch) String() string

type FilesToUpload

type FilesToUpload []string

Slice of name of file and directories to upload

func (*FilesToUpload) Set

func (a *FilesToUpload) Set(name string) error

func (*FilesToUpload) String

func (a *FilesToUpload) String() string

Jump to

Keyboard shortcuts

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