synctool

package
v0.0.0-...-56955ba Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UploadTargetFolderID is the ID of Google Drive folder where sender put the file to.
	UploadTargetFolderID = "1QaF-81k04ieUk4RB97PU1eALP0JnXN4S"

	// EncodeDoneFolderID is the ID of Google Drive folder where the original files are sent to after encoding process.
	EncodeDoneFolderID = "1i0GSCuF10lW1sx3A_vDGbvjAKIxPS2yM"

	// MP4TargetFolderID is the ID of Google Drive folder where encoded mp4 files are sent to.
	MP4TargetFolderID = "0B_fYUdOGrPfiUnR3aWVPMElHcjg"

	// DefaultSecretsFile is the filename of JSON file where OAuth2 secrets are recorded.
	// This file is available on https://console.developers.google.com/.
	DefaultSecretsFile = "client_secret.json"

	// Template URL string to open the Drive file with ID.
	GoogleDriveOpenURL = "https://drive.google.com/open?id=%s"
)

Variables

This section is empty.

Functions

func Loginfo

func Loginfo(f *drive.File) string

Loginfo returns as string in the required data inside *data.File.

Types

type File

type File struct {
	Path        string
	ID          string
	Downloaded  bool
	Encoded     bool
	EncodedPath string
	Uploaded    bool
}

File holds required info for encoding management.

func NewFile

func NewFile(path, id string) *File

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is the wrapper of Google Drive files service.

func NewManager

func NewManager(secrets string) *Manager

NewManager creates Manager with OAuth2 client secrets. It must call Init() method to activate actual drive.Service.

func (*Manager) AddFile

func (m *Manager) AddFile(f *File)

func (*Manager) Download

func (m *Manager) Download(id string) (int64, string, error)

Download fetches and creates a file from the path to current directory.

func (*Manager) Encode

func (m *Manager) Encode(id string) error

Encode start encoding using ffmpeg.

func (*Manager) FindFiles

func (m *Manager) FindFiles() ([]drive.File, error)

FindFiles get files in UploadTargetfolderid.

func (*Manager) FindNewFiles

func (m *Manager) FindNewFiles() ([]*File, error)

FindNewFiles checks new files uploaded on Google Drive and returns those.

func (*Manager) GetFile

func (m *Manager) GetFile(id string) *File

GetFile returns File instance with id from files field.

func (*Manager) Init

func (m *Manager) Init() error

Init creates http.Client based on oauth2.Config and holds drive.Service with hte credential.

func (*Manager) Move

func (m *Manager) Move(id string) error

Move transfers a file from upload target folder to encode done folder.

func (*Manager) NumFiles

func (m *Manager) NumFiles() int

NumFiles returns number of instance in files field.

func (*Manager) Perge

func (m *Manager) Perge() error

Perge removes all processed file instance from files field and delete all processed files from file system.

func (*Manager) SenderPerge

func (m *Manager) SenderPerge() error

SenderPerge checks if the file is uploaded and in encode done folder. If both are satisfiled, removes the original ts file.

func (*Manager) SenderUpload

func (m *Manager) SenderUpload()

func (*Manager) Upload

func (m *Manager) Upload(path, desc string, parents []string) (*drive.File, error)

Upload sends a file in path to directory id in Google Drive with the description.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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