picago

package
v0.0.0-...-ed6f70f Latest Latest
Warning

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

Go to latest
Published: May 19, 2014 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package picago contains functions for downloading albums and photos from Picasa Web. Implemented from scratch following https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol?hl=en .

Index

Constants

This section is empty.

Variables

View Source
var DebugDir string
View Source
var ErrCodeNeeded = errors.New("Authorization code is needed")

Functions

func Authorize

func Authorize(ID, secret string) error

Authorize authorizes using OAuth2 the ID and secret strings can be acquired from Google for the application https://developers.google.com/accounts/docs/OAuth2#basicsteps

func DownloadPhoto

func DownloadPhoto(client *http.Client, url string) (io.ReadCloser, error)

DownloadPhoto returns an io.ReadCloser for reading the photo bytes

func NewAuthorizeHandler

func NewAuthorizeHandler(transport *oauth.Transport, donech chan<- struct{}) http.HandlerFunc

NewAuthorizeHandler returns a http.HandlerFunc which will set the Token of the given oauth.Transport and send a struct{} on the donech on success.

func NewClient

func NewClient(id, secret, code, tokenCacheFilename string) (*http.Client, error)

NewClient returns an authorized http.Client usable for requests, caching tokens in the given file.

func NewClientCache

func NewClientCache(id, secret, code string, cache oauth.Cache) (*http.Client, error)

For redirect_uri, see https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi .

NewClientCache returns an authorized http.Client with the given oauth.Cache implementation

func NewTransport

func NewTransport(id, secret string, cache oauth.Cache) (*oauth.Transport, error)

Types

type Album

type Album struct {
	ID, Name, Title, Summary, Description, Location string
	AuthorName, AuthorURI                           string
	Keywords                                        []string
	Published, Updated                              time.Time
	URL                                             string
}

func GetAlbums

func GetAlbums(client *http.Client, userID string) ([]Album, error)

GetAlbums returns the list of albums of the given userID. If userID is empty, "default" is used.

type Atom

type Atom struct {
	ID           string    `xml:"id"`
	Name         string    `xml:"name"`
	Updated      time.Time `xml:"updated"`
	Title        string    `xml:"title"`
	Subtitle     string    `xml:"subtitle"`
	Icon         string    `xml:"icon"`
	Author       Author    `xml:"author"`
	NumPhotos    int       `xml:"numphotos"`
	StartIndex   int       `xml:"startIndex"`
	TotalResults int       `xml:"totalResults"`
	ItemsPerPage int       `xml:"itemsPerPage"`
	Entries      []Entry   `xml:"entry"`
}

func ParseAtom

func ParseAtom(r io.Reader) (*Atom, error)

type Author

type Author struct {
	Name string `xml:"name"`
	URI  string `xml:"uri"`
}

type Entry

type Entry struct {
	ETag      string       `xml:"etag,attr"`
	EntryID   string       `xml:"http://www.w3.org/2005/Atom id"`
	ID        string       `xml:"http://schemas.google.com/photos/2007 id"`
	Published time.Time    `xml:"published"`
	Updated   time.Time    `xml:"updated"`
	Name      string       `xml:"http://schemas.google.com/photos/2007 name"`
	Title     string       `xml:"title"`
	Summary   string       `xml:"summary"`
	Links     []Link       `xml:"link"`
	Author    Author       `xml:"author"`
	Location  string       `xml:"http://schemas.google.com/photos/2007 location"`
	NumPhotos int          `xml:"numphotos"`
	Content   EntryContent `xml:"content"`
	Media     Media        `xml:"group"`
	Exif      Exif         `xml:"tags"`
	Point     string       `xml:"where>Point>pos"`
}

type EntryContent

type EntryContent struct {
	URL  string `xml:"src,attr"`
	Type string `xml:"type,attr"`
}

type Exif

type Exif struct {
	FStop       float32 `xml:"fstop"`
	Make        string  `xml:"make"`
	Model       string  `xml:"model"`
	Exposure    float32 `xml:"exposure"`
	Flash       bool    `xml:"flash"`
	FocalLength float32 `xml:"focallength"`
	ISO         int32   `xml:"iso"`
	Timestamp   int64   `xml:"time"`
	UID         string  `xml:"imageUniqueID"`
}
type Link struct {
	Rel  string `xml:"rel,attr"`
	Type string `xml:"type,attr"`
	URL  string `xml:"href,attr"`
}

type Media

type Media struct {
	Title       string       `xml:"http://search.yahoo.com/mrss title"`
	Description string       `xml:"description"`
	Keywords    string       `xml:"keywords"`
	Content     MediaContent `xml:"content"`
}

type MediaContent

type MediaContent struct {
	URL  string `xml:"url,attr"`
	Type string `xml:"type,attr"`
}

type Photo

type Photo struct {
	ID, Title, Summary, Description, Location string
	Keywords                                  []string
	Published, Updated                        time.Time
	Latitude, Longitude                       float64
	URL, Type                                 string
	Exif                                      Exif
}

func GetPhotos

func GetPhotos(client *http.Client, userID, albumID string) ([]Photo, error)

func (Photo) Filename

func (p Photo) Filename() string

Filename returns the filename of the photo (from title or ID + type).

Jump to

Keyboard shortcuts

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