Documentation ¶
Index ¶
- Constants
- Variables
- func BodyToBytes(body io.Reader) []byte
- func BodyToString(body io.Reader) string
- func DumpRequest(request *http.Request)
- func DumpResponse(response *http.Response)
- func JsonBodyByScanLine(s string, start, end int) string
- func NewDataQuery(queryNumber int, query interface{}) string
- func NewJSONBody(model interface{}) io.Reader
- func NewJSONString(model interface{}) string
- func NewMutateQuery(queryNumber int, query interface{}) string
- func SpritMagicToken(t string) []string
- func UnixMiliSeconds() int64
- func WriteStringToFile(s string)
- type Album
- type AlbumlResponse
- type Albums
- type Client
- func (c *Client) AddPhotoToAlbum(albumID, photoID string) error
- func (c *Client) CreateAlbum(albumName string) (*Album, error)
- func (client *Client) DoQuery(endpoint string, query string) (io.ReadCloser, error)
- func (c *Client) ExportCookies() string
- func (client *Client) GetAlbums() (Albums, error)
- func (c *Client) GetSharedAlbumKey(albumID string) string
- func (c *Client) Login(user, pass string) error
- func (c *Client) RemoveFromAlbum(photoID string) error
- func (c *Client) SearchOrCreteaAlbum(name string) (*Album, error)
- func (c *Client) SetCookies(cookies ...*http.Cookie) *Client
- func (c *Client) SetHTTPClient(hClient *http.Client) *Client
- func (c *Client) Upload(filePath string, filename string, album string, ...) (*Photo, error)
- type CopyBufferResult
- type CreateSessionRequest
- type EnableImageResponse
- type ExternalField
- type ExternalFieldNewUpload
- type ExternalFieldTransfer
- type GoogleRupioAdditionalInfo
- type InlinedField
- type InlinedFieldObject
- type MagicToken
- type Photo
- type ProgressHandler
- type SessionRequest
- type SessionStatus
- type SessionUpload
- type UploadResult
- type Uploader
Constants ¶
View Source
const ( // ChromeUserAgent user-agent of chrome browser ChromeUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" // GooglePhotoURL the google photo homepage GooglePhotoURL = "https://photos.google.com" // GooglePhotoRequestUploadURL url to request create a new upload session GooglePhotoRequestUploadURL = "https://photos.google.com/_/upload/uploadmedia/rupio/interactive?authuser=0" // GooglePhotoMutateQueryURL url to execute a specific command GooglePhotoMutateQueryURL = "https://photos.google.com/_/PhotosUi/mutate" // GooglePhotoDataQueryURL url do something GooglePhotoDataQueryURL = "https://photos.google.com/_/PhotosUi/data" // GoogleCommandDataURL GoogleCommandDataURL = "" /* 164-byte string literal not displayed */ // GoogleLoginSite the url to login GoogleLoginSite = "https://accounts.google.com/ServiceLogin" // DefaultAlbum a required album need to do a magic thing DefaultAlbum = "DefaultAlbum" )
View Source
const ( QueryNumberEnableImage = 137530650 QueryNumberGetAlbum = 72930366 QueryNumberCreateAlbum = 79956622 QueryNumberAddPhotoToAlbum = 79956622 QueryNumberRemovePhotoFromAlbum = 85381832 QueryStringAddPhotoToAlbum = "C2V01c" )
Variables ¶
View Source
var ( //ErrorUnknow For unexpected error ErrorUnknow = errors.New("Unknow Error") // ErrorAlbumNotCreatedYet In case no album was created just return it ErrorAlbumNotCreatedYet = errors.New("There is no album was created") )
View Source
var (
HomePageURL, _ = url.Parse(GooglePhotoURL)
)
Functions ¶
func BodyToBytes ¶
func BodyToString ¶
func DumpRequest ¶
func DumpResponse ¶
func JsonBodyByScanLine ¶
func NewDataQuery ¶
func NewJSONBody ¶
NewJSONBody create a new json request body from an interface
func NewJSONString ¶
func NewJSONString(model interface{}) string
func NewMutateQuery ¶
func SpritMagicToken ¶
func UnixMiliSeconds ¶
func UnixMiliSeconds() int64
func WriteStringToFile ¶
func WriteStringToFile(s string)
Types ¶
type AlbumlResponse ¶
type AlbumlResponse struct {
// contains filtered or unexported fields
}
func NewAlbumlResponse ¶
func NewAlbumlResponse(s string) *AlbumlResponse
func (*AlbumlResponse) Albums ¶
func (al *AlbumlResponse) Albums() (albums []*Album, err error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client present a upload client
func (*Client) AddPhotoToAlbum ¶
AddPhotoToAlbum adds a photo to an album
func (*Client) CreateAlbum ¶
CreateAlbum creates a new album
func (*Client) ExportCookies ¶
func (*Client) GetSharedAlbumKey ¶
GetSharedAlbumKey gets an album's share key
func (*Client) RemoveFromAlbum ¶
RemoveFromAlbum Remove a photo from an album
func (*Client) SearchOrCreteaAlbum ¶
SearchOrCreteaAlbum creates an album if the album name doesn't exist
func (*Client) SetCookies ¶
SetCookies attach google's cookies to the upload client
func (*Client) SetHTTPClient ¶
SetHTTPClient specific the http client to the upload client.
type CopyBufferResult ¶
type CreateSessionRequest ¶
type CreateSessionRequest struct {
Fields []interface{} `json:"fields"`
}
type EnableImageResponse ¶
type EnableImageResponse []interface{}
type ExternalField ¶
type ExternalField struct {
Field interface{} `json:"external"`
}
type ExternalFieldNewUpload ¶
type ExternalFieldTransfer ¶
type GoogleRupioAdditionalInfo ¶
type GoogleRupioAdditionalInfo struct { CompletionInfo struct { CustomerSpecificInfo struct { UploadToken string `json:"upload_token_base64"` } `json:"customerSpecificInfo"` } `json:"completionInfo"` }
type InlinedField ¶
type InlinedField struct {
Inlined InlinedFieldObject `json:"inlined"`
}
type InlinedFieldObject ¶
type MagicToken ¶
type MagicToken struct {
Token string `json:"SNlM0e"`
}
type ProgressHandler ¶
type SessionRequest ¶
type SessionRequest struct { ProtocolVersion string `json:"protocolVersion"` CreateSessionRequest CreateSessionRequest `json:"createSessionRequest"` }
func NewUploadSessionRequest ¶
func NewUploadSessionRequest(fileName string, fileSize int64) *SessionRequest
type SessionStatus ¶
type SessionStatus struct { State string `json:"state"` ExternalFieldTransfers []*ExternalFieldTransfer `json:"externalFieldTransfers"` UploadID string `json:"upload_id"` DropZoneLabel string `json:"drop_zone_label"` AdditionalInfo struct { GoogleRupioAdditionalInfo GoogleRupioAdditionalInfo `json:"uploader_service.GoogleRupioAdditionalInfo"` } `json:"additionalInfo"` }
type SessionUpload ¶
type SessionUpload struct {
SessionStatus SessionStatus `json:"sessionStatus"`
}
func NewSessionUploadFromJson ¶
func NewSessionUploadFromJson(body string) *SessionUpload
type UploadResult ¶
Click to show internal directories.
Click to hide internal directories.