Documentation ¶
Overview ¶
Package that contains the models of the JSON objects used in the requests and responses and the methods to create new objects that describes the API actions, like the Upload or the AtTokenScraper
Index ¶
- Constants
- Variables
- func AlbumAddMediaItems(credentials auth.CookieCredentials, albumId string, items []string) error
- func AlbumShareAddUser(credentials auth.CookieCredentials, sharedAlbumId string, user string) error
- func AlbumShareWithUser(credentials auth.CookieCredentials, albumId string, user string) (string, error)
- func AlbumSortMediaItems(credentials auth.CookieCredentials, albumId string, kind int) error
- func CreateAlbum(credentials auth.CookieCredentials, albumName string) (string, error)
- func DeleteAlbum(credentials auth.CookieCredentials, albumId string, sharedAlbumId interface{}) error
- func DeleteEmptyAlbums(credentials auth.CookieCredentials) ([]Album, []Album, []Album, error)
- func DeleteMediaItems(credentials auth.CookieCredentials, mediaItemIds []string, kind int) error
- func EmptyTrash(credentials auth.CookieCredentials) error
- type Album
- type ApiTokenContainer
- type AtTokenScraper
- type CreateSessionRequest
- type ExternalField
- type ExternalFieldObject
- type InlinedField
- type InlinedFieldObject
- type MediaItem
- func ListAllMediaItemsBefore(credentials auth.CookieCredentials, before interface{}, ...) ([]MediaItem, error)
- func ListAllUnsupportedMediaItemsBefore(credentials auth.CookieCredentials, cb func([]MediaItem, error)) ([]MediaItem, error)
- func ListMediaItems(credentials auth.CookieCredentials, before interface{}, pageToken interface{}) ([]MediaItem, interface{}, error)
- func ListUnsupportedMediaItems(credentials auth.CookieCredentials, pageToken interface{}) ([]MediaItem, interface{}, error)
- type RequestUploadURL
- type TimelineEntry
- type Upload
- type UploadOptions
- type UploadResult
Constants ¶
const (
GooglePhotoUrl = "https://photos.google.com/"
)
const (
// NewUploadURL : Url to which send the request to get a new url to upload a new image
NewUploadURL = "https://photos.google.com/_/upload/uploadmedia/rupio/interactive?authuser=2"
)
Variables ¶
var (
LogRequests bool
)
var (
RegexUploadedImageURL = regexp.MustCompile(`^https://(?:lh3\.googleusercontent\.com|photos\.fife\.usercontent\.google\.com)/([\w-/]+)$`)
)
Functions ¶
func AlbumAddMediaItems ¶
func AlbumAddMediaItems(credentials auth.CookieCredentials, albumId string, items []string) error
func AlbumShareAddUser ¶
func AlbumShareAddUser(credentials auth.CookieCredentials, sharedAlbumId string, user string) error
Add a new user to a Album share
func AlbumShareWithUser ¶
func AlbumShareWithUser(credentials auth.CookieCredentials, albumId string, user string) (string, error)
Share Album
func AlbumSortMediaItems ¶
func AlbumSortMediaItems(credentials auth.CookieCredentials, albumId string, kind int) error
func CreateAlbum ¶
func CreateAlbum(credentials auth.CookieCredentials, albumName string) (string, error)
Create Album
func DeleteAlbum ¶
func DeleteAlbum(credentials auth.CookieCredentials, albumId string, sharedAlbumId interface{}) error
Delete Albums albumId: Own albumId (AF1QipP5CHoTNeAsjAdNQDbfaWTI0A2oJp_er5PSNSFs) sharedAlbumId: Shared album Id (AF1QipN4Q7SPvfG2agzCI_ZTH2Hp7zNTGSOcH4MhUuCmNHxKr1JfU3Uz-vg7heZ2z195PA)
func DeleteEmptyAlbums ¶
Delete empty albums
func DeleteMediaItems ¶
func DeleteMediaItems(credentials auth.CookieCredentials, mediaItemIds []string, kind int) error
DeleteMediaItems a media item kind=1 for Send to trash kind=2 for Immediate deletion kind=3 for Restore from trash
Types ¶
type Album ¶
type Album struct { // Album identifier AlbumId string SharedAlbumId interface{} // Album name AlbumName string // Number of media items in the album MediaCount int64 }
Album represents an album
func ListAlbums ¶
func ListAlbums(credentials auth.CookieCredentials, pageToken interface{}) ([]Album, interface{}, error)
List albums by page
func ListAllAlbums ¶
List all albums
type ApiTokenContainer ¶
type ApiTokenContainer struct {
Token string `json:"SNlM0e"`
}
type AtTokenScraper ¶
type AtTokenScraper struct {
// contains filtered or unexported fields
}
AtTokenScraper used to scape tokens to upload images
func NewAtTokenScraper ¶
func NewAtTokenScraper(credentials auth.CookieCredentials) *AtTokenScraper
Create a new scraper for the at token. This token is user-dependent, so you need to create a new token scraper for each Credentials object.
func (*AtTokenScraper) ScrapeNewAtToken ¶
func (ts *AtTokenScraper) ScrapeNewAtToken() (string, error)
Use this method to get a new at token. The method makes an http request to Google and uses the user credentials
type CreateSessionRequest ¶
type CreateSessionRequest struct {
// The fields array is a slice that should contain only ExternalField or InternalField structs
Fields []interface{} `json:"fields"`
}
Inner object of the request to get a new url to upload a photo.
type ExternalField ¶
type ExternalField struct {
External ExternalFieldObject `json:"external"`
}
Possible field for the Fields slice in the CreateSessionRequest struct
type ExternalFieldObject ¶
type ExternalFieldObject struct { Name string `json:"name"` Filename string `json:"filename"` Size int64 `json:"size"` }
Describes the file that need to be uploaded. This objects should be contained in a ExternalField
type InlinedField ¶
type InlinedField struct {
Inlined InlinedFieldObject `json:"inlined"`
}
Possible field for the Fields slice in the CreateSessionRequest struct
type InlinedFieldObject ¶
type InlinedFieldObject struct { Name string `json:"name"` Content string `json:"content"` ContentType string `json:"contentType"` }
Used to define parameters of the upload. This object should be contained in a InternalField
type MediaItem ¶
type MediaItem struct { // Media item identifier MediaItemId string // Media item content URL ContentUrl string // Media item width ContentWidth int64 // Media item height ContentHeight int64 // Date of the media item start StartDate int64 // Date of the media item end EndDate int64 // Some kind of media item serial number? MediaItemSn int64 // Media item download URL DownloadUrl string // Filename of the media item Filename string }
MediaItem represents a media item (picture, video)
func ListAllMediaItemsBefore ¶
func ListAllMediaItemsBefore(credentials auth.CookieCredentials, before interface{}, cb func([]MediaItem, error)) ([]MediaItem, error)
List all media items before a date
func ListAllUnsupportedMediaItemsBefore ¶
func ListAllUnsupportedMediaItemsBefore(credentials auth.CookieCredentials, cb func([]MediaItem, error)) ([]MediaItem, error)
List all unsupported media items
func ListMediaItems ¶
func ListMediaItems(credentials auth.CookieCredentials, before interface{}, pageToken interface{}) ([]MediaItem, interface{}, error)
List media items by page
func ListUnsupportedMediaItems ¶
func ListUnsupportedMediaItems(credentials auth.CookieCredentials, pageToken interface{}) ([]MediaItem, interface{}, error)
List unsupported media items by page
type RequestUploadURL ¶
type RequestUploadURL struct { ProtocolVersion string `json:"protocolVersion"` CreateSessionRequest CreateSessionRequest `json:"createSessionRequest"` }
Structure of the JSON object that it's sent to request a new url to upload a new photo
type TimelineEntry ¶
type TimelineEntry struct {
// contains filtered or unexported fields
}
TimelineEntry represents an entry of the timeline
func GetTimelineEntries ¶
func GetTimelineEntries(credentials auth.CookieCredentials, pageToken interface{}) ([]TimelineEntry, interface{}, error)
Get timeline entries by page
func GetWholeTimeline ¶
func GetWholeTimeline(credentials auth.CookieCredentials) ([]TimelineEntry, error)
Get whole timeline
type Upload ¶
type Upload struct { // Options of the upload Options *UploadOptions // Credentials to used to send the requests Credentials auth.CookieCredentials // contains filtered or unexported fields }
Upload represents an upload, generated by an UploadOptions
func NewUpload ¶
func NewUpload(options *UploadOptions, credentials auth.CookieCredentials) (*Upload, error)
NewUpload creates a new Upload given an UploadOptions and a Credentials implementation. This method return an error if the upload options struct it's not usable to create a new upload
func (*Upload) Upload ¶
func (u *Upload) Upload() (*UploadResult, error)
Upload tries to upload an image, making multiple http requests. It returns a response event if there is an error
type UploadOptions ¶
type UploadOptions struct { // Required field, a stream from which read the image. // You need to close the stream when the image is uploaded Stream io.Reader // Required field, size of the photo FileSize int64 // Name of the photo (optional) Name string // UNIX timestamp of the photo (optional) Timestamp int64 // Optional album id AlbumId string }
UploadOptions contains the Upload options
func NewUploadOptionsFromFile ¶
func NewUploadOptionsFromFile(file *os.File) (*UploadOptions, error)
NewUploadOptionsFromFile creates a new UploadOptions from a file
type UploadResult ¶
func (*UploadResult) URLString ¶
func (ur *UploadResult) URLString() string