photo

package
v0.0.0-...-519d24f Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessPublic    Access = "public"
	AccessPrivate          = "private"
	AccessProtected        = "protected"
)

Available Access values

View Source
const BaseURL = "https://picasaweb.google.com"

BaseURL is a base url for Google Photo API

View Source
const RedirectURL = "urn:ietf:wg:oauth:2.0:oob"

RedirectURL is a string passed for oauth

Variables

This section is empty.

Functions

func NewOAuth2Config

func NewOAuth2Config(clientID, clientSecret string) *oauth2.Config

NewOAuth2Config returns a new *oauth2.Config for Google Photo endpoint.

Types

type Access

type Access string

Access is alias for access scope string

type Album

type Album struct {
	XMLName            xml.Name   `xml:"http://www.w3.org/2005/Atom entry"`
	XMLNSMedia         string     `xml:"xmlns:media,attr"`
	XMLNSGPhoto        string     `xml:"xmlns:gphoto,attr"`
	ID                 string     `xml:"http://schemas.google.com/photos/2007 id,omitempty"`
	PublishedAt        *time.Time `xml:"published,omitempty"` // use pointer to make 'omitempty' work
	UpdatedAt          *time.Time `xml:"updated,omitempty"`   // use pointer to make 'omitempty' work
	Title              string     `xml:"title"`
	Summary            string     `xml:"summary"`
	Category           *Category  `xml:"category"`
	Timestamp          int64      `xml:"http://schemas.google.com/photos/2007 timestamp,omitempty"`
	Access             Access     `xml:"http://schemas.google.com/photos/2007 access,omitempty"`
	Location           string     `xml:"http://schemas.google.com/photos/2007 location,omitempty"`
	AuthorID           string     `xml:"http://schemas.google.com/photos/2007 user,omitempty"`
	AuthorName         string     `xml:"http://schemas.google.com/photos/2007 nickname,omitempty"`
	NumPhotos          int        `xml:"http://schemas.google.com/photos/2007 numphotos,omitempty"`
	NumPhotosRemaining int        `xml:"http://schemas.google.com/photos/2007 numphotosremaining,omitempty"`
	BytesUsed          int64      `xml:"http://schemas.google.com/photos/2007 bytesUsed,omitempty"`
}

Album represents an album data

func NewAlbum

func NewAlbum() *Album

NewAlbum returns a new *Album

func (*Album) String

func (a *Album) String() string

type Category

type Category struct {
	Scheme string `xml:"scheme,attr"`
	Term   string `xml:"term,attr"`
}

Category represents the category field in an album

type Client

type Client struct {
	BaseURL string
	// contains filtered or unexported fields
}

Client is a client for Gootle Photo API

func NewClient

func NewClient(client *http.Client) *Client

NewClient returns a new *Client

func (*Client) CreateAlbum

func (c *Client) CreateAlbum(userID string, a *Album) (*Album, error)

CreateAlbum creats a new album

func (*Client) CreateAlbumByName

func (c *Client) CreateAlbumByName(userID string, albumName string) (*Album, error)

CreateAlbumByName creates a new album with the given album name

func (*Client) DeleteAlbum

func (c *Client) DeleteAlbum(userID string, albumID string) error

DeleteAlbum delets the album.

func (*Client) DeleteMedia

func (c *Client) DeleteMedia(userID string, albumID string, mediaID string) error

DeleteMedia delets a media

func (*Client) GetMedia

func (c *Client) GetMedia(userID, albumID, mediaID string) (*Media, error)

GetMedia returns a *Media specified by mediaID

func (*Client) ListAlbums

func (c *Client) ListAlbums(userID string) ([]*Album, error)

ListAlbums returns a list of albums

func (*Client) ListMedia

func (c *Client) ListMedia(userID, albumID string) ([]*Media, error)

ListMedia returns the list of media in an album

func (*Client) UploadMedia

func (c *Client) UploadMedia(userID, albumID string, m *UploadMediaInfo, contentType string, contentLength int64, r io.Reader) (*Media, error)

UploadMedia uploads a new media. Currently only photos are supported.

type Content

type Content struct {
	URL    string `xml:"url,attr"`
	Width  int    `xml:"width,attr"`
	Height int    `xml:"height,attr"`
	Type   string `xml:"type,attr"`
	Medium string `xml:"medium,attr"`
}

Content represents content field data

type Media

type Media struct {
	ID            string         `xml:"http://schemas.google.com/photos/2007 id,omitempty"`
	AlbumID       string         `xml:"http://schemas.google.com/photos/2007 albumid,omitempty"`
	Title         string         `xml:"title"`
	PublishedAt   *time.Time     `xml:"published,omitempty"`
	UpdatedAt     *time.Time     `xml:"updated,omitempty"`
	Summary       string         `xml:"summary"`
	Category      *Category      `xml:"category"`
	Size          int64          `xml:"http://schemas.google.com/photos/2007 size,omitempty"`
	Width         int            `xml:"http://schemas.google.com/photos/2007 width,omitempty"`
	Height        int            `xml:"http://schemas.google.com/photos/2007 height,omitempty"`
	VideoStatus   string         `xml:"http://schemas.google.com/photos/2007 videostatus,omitempty"`
	OriginalVideo *OriginalVideo `xml:"http://schemas.google.com/photos/2007 originalvideo,omitempty"`
	Contents      []*Content     `xml:"http://search.yahoo.com/mrss/ group>content,omitempty"`
	Thumbnails    []*Thumbnail   `xml:"http://search.yahoo.com/mrss/ group>thumbnail,omitempty"`
}

Media represents media data

type OriginalVideo

type OriginalVideo struct {
	Width        int     `xml:"width,attr"`
	Height       int     `xml:"height,attr"`
	Duration     int     `xml:"duration,attr"`
	Type         string  `xml:"type,attr"`
	Channels     int     `xml:"channels,attr"`
	SamplingRate float32 `xml:"samplingrate,attr"`
	VideoCodec   string  `xml:"videoCodec,attr"`
	AudioCodec   string  `xml:"audioCodec,attr"`
	Fps          float32 `xml:"fps,attr"`
}

OriginalVideo represents original_video field data.

type Thumbnail

type Thumbnail struct {
	URL    string `xml:"url,attr"`
	Width  int    `xml:"width,attr"`
	Height int    `xml:"height,attr"`
}

Thumbnail represents thumbnail field data

type UploadMediaInfo

type UploadMediaInfo struct {
	XMLName     xml.Name  `xml:"http://www.w3.org/2005/Atom entry"`
	XMLNSMedia  string    `xml:"xmlns:media,attr"`
	XMLNSGPhoto string    `xml:"xmlns:gphoto,attr"`
	Title       string    `xml:"title"`
	Summary     string    `xml:"summary"`
	Category    *Category `xml:"category"`
	Client      string    `xml:"gphoto:client"`
}

UploadMediaInfo is a struct used for uploading a media

func NewUploadMediaInfo

func NewUploadMediaInfo(title string) *UploadMediaInfo

NewUploadMediaInfo returns a new *UploadMediaInfo

Jump to

Keyboard shortcuts

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