gonedrive

package module
v0.0.0-...-8c13306 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: MIT Imports: 11 Imported by: 0

README

gonedrive

Small OneDrive library for Go

Made for practice, and for use in another personal project. May/may not be updated further down the road.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildrenResponse

type ChildrenResponse struct {
	Context  string       `json:"@odata.context"`
	Count    int          `json:"@odata.count"`
	NextLink string       `json:"@odata.nextLink"`
	Data     []*DriveItem `json:"value"`
}

type DriveItem

type DriveItem struct {
	Id           string `json:"id"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	Size         int    `json:"size"`
	WebURL       string `json:"webUrl"`
	Ctag         string `json:"cTag"`
	Etag         string `json:"eTag"`
	CreationDate string `json:"createdDateTime"`
	ModifiedDate string `json:"lastModifiedDateTime"`

	Root        *struct{} `json:"root"`
	DownloadURL string    `json:"@content.downloadUrl"`

	Audio *struct {
		Album             string `json:"album"`
		AlbumArtist       string `json:"albumArtist"`
		Artist            string `json:"Artist"`
		Bitrate           int    `json:"bitrate"`
		Composers         string `json:"composers"`
		Copyright         string `json:"copyright"`
		Disc              int    `json:"disc"`
		DiscCount         int    `json:"discCount"`
		Duration          int    `json:"duration"`
		Genre             string `json:"genre"`
		HasDRM            bool   `json:"hasDrm"`
		IsVariableBitrate bool   `json:"isVariableBitrate"`
		Title             string `json:"title"`
		Track             int    `json:"track"`
		TrackCount        int    `json:"trackCount"`
		Year              int    `json:"year"`
	} `json:"audio"`

	File *struct {
		MimeType string  `json:"mimeType"`
		Hashes   *Hashes `json:"hashes"`
	} `json:"file"`

	Folder *struct {
		ChildCount int `json:"childCount"`
		View       *struct {
			SortBy    string `json:"sortBy"`
			SortOrder string `json:"sortOrder"`
			ViewType  string `json:"viewType"`
		} `json:"view"`
	} `json:"folder"`
}

type ErrorResponse

type ErrorResponse struct {
	Outer struct {
		Code    string `json:"code"`
		Message string `json:"message"`
		Inner   struct {
			Date            string `json:"date"`
			RequestID       string `json:"request-id"`
			ClientRequestId string `json:"client-request-id"`
		} `json:"innerError"`
	} `json:"error"`
}

func (*ErrorResponse) Error

func (err *ErrorResponse) Error() string

type GraphToken

type GraphToken struct {
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	// contains filtered or unexported fields
}

func CreateAccess

func CreateAccess(clientID string, redirectURI string, fname string) (*GraphToken, error)

func (*GraphToken) DownloadFile

func (t *GraphToken) DownloadFile(file *DriveItem) ([]byte, error)

Downloads a DriveItem, and returns the file body.

func (*GraphToken) ListFile

func (t *GraphToken) ListFile(path string) (*DriveItem, error)

Get DriveItem information for a single file. Path should be WITHOUT leading/trailing slashes.

func (*GraphToken) ListFolder

func (t *GraphToken) ListFolder(path string) ([]*DriveItem, error)

Lists all files in a given folder. Path should be WITHOUT leading/trailing slashes.

func (*GraphToken) MakeRequest

func (t *GraphToken) MakeRequest(method string, url string, body io.Reader) (*http.Response, error)

func (*GraphToken) SyncFolder

func (t *GraphToken) SyncFolder(odpath string, destpath string, filetype string) error

A read-only sync of a given OneDrive folder. Downloads files that don't exist in local directory. Deletes files in local directory not found on OneDrive. Does not redownload existing files. Creates a json file in the target directory to store state of synced files.

type Hashes

type Hashes struct {
	Crc32    string `json:"crc32Hash"`
	Sha1     string `json:"sha1Hash"`
	Sha256   string `json:"sha256Hash"`
	QuickXor string `json:"quickXorHash"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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