internal

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlbumNameAll             = "All Photos"
	AlbumNameTimeLapse       = "Time-lapse"
	AlbumNameVideos          = "Videos"
	AlbumNameSloMo           = "Slo-mo"
	AlbumNameBursts          = "Bursts"
	AlbumNameFavorites       = "Favorites"
	AlbumNamePanoramas       = "Panoramas"
	AlbumNameScreenshots     = "Screenshots"
	AlbumNameLive            = "Live"
	AlbumNameRecentlyDeleted = "Recently Deleted"
	AlbumNameHidden          = "Hidden"
)
View Source
const (
	DriveRootID  = "FOLDER::com.apple.CloudDocs::root"
	DriveTrashID = "TRASH_ROOT"
)

Variables

View Source
var (
	ErrValidateCodeWrong = NewError("-21669", "validate code wrong")
	ErrPhotosIterateEnd  = NewError("photos_iterate_end", "photos iterate end")
	ErrResourceGone      = NewHttpError(410, "resource gone")
)

Functions

func IsErrorCode

func IsErrorCode(err error, code string) bool

Types

type Client

type Client struct {
	Data *ValidateData
	// contains filtered or unexported fields
}

func NewClient

func NewClient(option *ClientOption) (*Client, error)

func (*Client) Authenticate

func (r *Client) Authenticate(forceRefresh bool, service *string) (finalErr error)

func (*Client) Close

func (r *Client) Close() error

func (*Client) ConfigPath added in v0.8.0

func (r *Client) ConfigPath(configName string) string

func (*Client) DriveCli added in v0.8.0

func (r *Client) DriveCli() (*DriveService, error)

func (*Client) LoadConfig added in v0.8.0

func (r *Client) LoadConfig(configName string) ([]byte, error)

func (*Client) PhotoCli

func (r *Client) PhotoCli() (*PhotoService, error)

func (*Client) SaveConfig added in v0.8.0

func (r *Client) SaveConfig(configName string, data []byte) error

type ClientOption

type ClientOption struct {
	AppID           string
	CookieDir       string
	PasswordGetter  TextGetter
	TwoFACodeGetter TextGetter
	Domain          string // com,cn
}

type DriveFolder added in v0.8.0

type DriveFolder struct {
	DateCreated         time.Time `json:"dateCreated"`
	Drivewsid           string    `json:"drivewsid"`
	Docwsid             string    `json:"docwsid"`
	Zone                string    `json:"zone"`
	Name                string    `json:"name"`
	ParentId            string    `json:"parentId"`
	Etag                string    `json:"etag"`
	Type                string    `json:"type"`
	AssetQuota          int       `json:"assetQuota,omitempty"`
	FileCount           int       `json:"fileCount,omitempty"`
	ShareCount          int       `json:"shareCount,omitempty"`
	ShareAliasCount     int       `json:"shareAliasCount,omitempty"`
	DirectChildrenCount int       `json:"directChildrenCount,omitempty"`
	MaxDepth            string    `json:"maxDepth,omitempty"`
	Icons               []struct {
		Url  string `json:"url"`
		Type string `json:"type"`
		Size int    `json:"size"`
	} `json:"icons,omitempty"`
	SupportedExtensions []string  `json:"supportedExtensions,omitempty"`
	SupportedTypes      []string  `json:"supportedTypes,omitempty"`
	Extension           string    `json:"extension,omitempty"`
	DateModified        time.Time `json:"dateModified,omitempty"`
	DateChanged         time.Time `json:"dateChanged,omitempty"`
	Size                int       `json:"size,omitempty"`
}

type DriveService added in v0.8.0

type DriveService struct {
	// contains filtered or unexported fields
}

func (*DriveService) CreateFolder added in v0.8.0

func (r *DriveService) CreateFolder(parentDriveID, name string) (*DriveFolder, error)

func (*DriveService) Folders added in v0.8.0

func (r *DriveService) Folders(driveID string) (int, []*DriveFolder, error)

type Error

type Error struct {
	HttpStatus int
	Code       string
	Message    string
}

func NewError

func NewError(code string, message string) *Error

func NewHttpError added in v0.12.0

func NewHttpError(httpStatus int, body string) *Error

func (*Error) Error

func (e *Error) Error() string

type PhotoAlbum

type PhotoAlbum struct {

	// attr
	Name        string
	ListType    string
	ObjType     string
	Direction   string
	QueryFilter []*folderMetaDataQueryFilter
	// contains filtered or unexported fields
}

func (*PhotoAlbum) GetPhotosByCount

func (r *PhotoAlbum) GetPhotosByCount(count int) ([]*PhotoAsset, error)

func (*PhotoAlbum) GetPhotosByOffset

func (r *PhotoAlbum) GetPhotosByOffset(offset, limit int64) ([]*PhotoAsset, error)

func (*PhotoAlbum) GetSize

func (r *PhotoAlbum) GetSize() (int64, error)

func (*PhotoAlbum) PhotosIter

func (r *PhotoAlbum) PhotosIter(startOffset int64) PhotosIterNext

func (*PhotoAlbum) Size

func (r *PhotoAlbum) Size() int64

func (*PhotoAlbum) WalkPhotos added in v0.9.0

func (r *PhotoAlbum) WalkPhotos(offset int64, f func(offset int64, assets []*PhotoAsset) error) error

type PhotoAsset

type PhotoAsset struct {
	// contains filtered or unexported fields
}

func (*PhotoAsset) AddDate added in v0.21.1

func (r *PhotoAsset) AddDate() time.Time

func (*PhotoAsset) AssetDate added in v0.21.1

func (r *PhotoAsset) AssetDate() time.Time

func (*PhotoAsset) Bytes added in v0.9.0

func (r *PhotoAsset) Bytes() []byte

func (*PhotoAsset) Delete added in v0.4.0

func (r *PhotoAsset) Delete() error

func (*PhotoAsset) Download

func (r *PhotoAsset) Download(version PhotoVersion, livePhoto bool) (io.ReadCloser, error)

func (*PhotoAsset) DownloadTo added in v0.5.0

func (r *PhotoAsset) DownloadTo(version PhotoVersion, livePhoto bool, target string) error

func (*PhotoAsset) Filename

func (r *PhotoAsset) Filename(livePhoto bool) string

func (*PhotoAsset) FormatSize

func (r *PhotoAsset) FormatSize() string

func (*PhotoAsset) ID

func (r *PhotoAsset) ID() string

func (*PhotoAsset) IsLivePhoto added in v0.21.1

func (r *PhotoAsset) IsLivePhoto() bool

func (*PhotoAsset) LocalPath added in v0.4.0

func (r *PhotoAsset) LocalPath(outputDir string, size PhotoVersion, fileStructure string, livePhoto bool) string

func (*PhotoAsset) OldOutputDir added in v0.21.1

func (r *PhotoAsset) OldOutputDir(output, folderStructure string) string

仅为兼容性

func (*PhotoAsset) OutputDir added in v0.10.0

func (r *PhotoAsset) OutputDir(output, folderStructure string) string

func (*PhotoAsset) Size

func (r *PhotoAsset) Size() int

type PhotoService

type PhotoService struct {
	// contains filtered or unexported fields
}

func (*PhotoService) Albums

func (r *PhotoService) Albums() (map[string]*PhotoAlbum, error)

func (*PhotoService) GetAlbum added in v0.4.0

func (r *PhotoService) GetAlbum(albumName string) (*PhotoAlbum, error)

func (*PhotoService) NewPhotoAssetFromBytes added in v0.9.0

func (r *PhotoService) NewPhotoAssetFromBytes(bs []byte) *PhotoAsset

func (*PhotoService) Upload added in v0.2.0

func (r *PhotoService) Upload(filename string, file io.Reader) (bool, error)

type PhotoVersion

type PhotoVersion string
const (
	PhotoVersionOriginal PhotoVersion = "original"
	PhotoVersionMedium   PhotoVersion = "medium"
	PhotoVersionThumb    PhotoVersion = "thumb"
)

type PhotosIterNext

type PhotosIterNext interface {
	Next() (*PhotoAsset, error)
	Offset() int64
}

type SessionData

type SessionData struct {
	SessionToken   string `json:"session_token"`
	Scnt           string `json:"scnt"`
	SessionID      string `json:"session_id"`
	AccountCountry string `json:"account_country"`
	TrustToken     string `json:"trust_token"`
}

type TextGetter

type TextGetter func(appleID string) (string, error)

type User

type User struct {
	AccountName string `json:"accountName"`
	Password    string `json:"password"`
}

type ValidateData

type ValidateData struct {
	DsInfo                       *ValidateDataDsInfo    `json:"dsInfo"`
	HasMinimumDeviceForPhotosWeb bool                   `json:"hasMinimumDeviceForPhotosWeb"`
	ICDPEnabled                  bool                   `json:"iCDPEnabled"`
	Webservices                  map[string]*webService `json:"webservices"`
	PcsEnabled                   bool                   `json:"pcsEnabled"`
	TermsUpdateNeeded            bool                   `json:"termsUpdateNeeded"`
	ConfigBag                    struct {
		Urls struct {
			AccountCreateUI     string `json:"accountCreateUI"`
			AccountLoginUI      string `json:"accountLoginUI"`
			AccountLogin        string `json:"accountLogin"`
			AccountRepairUI     string `json:"accountRepairUI"`
			DownloadICloudTerms string `json:"downloadICloudTerms"`
			RepairDone          string `json:"repairDone"`
			AccountAuthorizeUI  string `json:"accountAuthorizeUI"`
			VettingUrlForEmail  string `json:"vettingUrlForEmail"`
			AccountCreate       string `json:"accountCreate"`
			GetICloudTerms      string `json:"getICloudTerms"`
			VettingUrlForPhone  string `json:"vettingUrlForPhone"`
		} `json:"urls"`
		AccountCreateEnabled bool `json:"accountCreateEnabled"`
	} `json:"configBag"`
	HsaTrustedBrowser            bool     `json:"hsaTrustedBrowser"`
	AppsOrder                    []string `json:"appsOrder"`
	Version                      int      `json:"version"`
	IsExtendedLogin              bool     `json:"isExtendedLogin"`
	PcsServiceIdentitiesIncluded bool     `json:"pcsServiceIdentitiesIncluded"`
	IsRepairNeeded               bool     `json:"isRepairNeeded"`
	HsaChallengeRequired         bool     `json:"hsaChallengeRequired"`
	RequestInfo                  struct {
		Country  string `json:"country"`
		TimeZone string `json:"timeZone"`
		Region   string `json:"region"`
	} `json:"requestInfo"`
	PcsDeleted bool `json:"pcsDeleted"`
	ICloudInfo struct {
		SafariBookmarksHasMigratedToCloudKit bool `json:"SafariBookmarksHasMigratedToCloudKit"`
	} `json:"iCloudInfo"`
	Apps map[string]*ValidateDataApp `json:"apps"`
}

type ValidateDataApp

type ValidateDataApp struct {
	CanLaunchWithOneFactor bool `json:"canLaunchWithOneFactor"` // Find
	IsQualifiedForBeta     bool `json:"isQualifiedForBeta"`     // Numbers
}

type ValidateDataDsInfo

type ValidateDataDsInfo struct {
	HsaVersion                         int           `json:"hsaVersion"`
	LastName                           string        `json:"lastName"`
	ICDPEnabled                        bool          `json:"iCDPEnabled"`
	TantorMigrated                     bool          `json:"tantorMigrated"`
	Dsid                               string        `json:"dsid"`
	HsaEnabled                         bool          `json:"hsaEnabled"`
	IsHideMyEmailSubscriptionActive    bool          `json:"isHideMyEmailSubscriptionActive"`
	IroncadeMigrated                   bool          `json:"ironcadeMigrated"`
	Locale                             string        `json:"locale"`
	BrZoneConsolidated                 bool          `json:"brZoneConsolidated"`
	ICDRSCapableDeviceList             string        `json:"ICDRSCapableDeviceList"`
	IsManagedAppleID                   bool          `json:"isManagedAppleID"`
	IsCustomDomainsFeatureAvailable    bool          `json:"isCustomDomainsFeatureAvailable"`
	IsHideMyEmailFeatureAvailable      bool          `json:"isHideMyEmailFeatureAvailable"`
	ContinueOnDeviceEligibleDeviceInfo []string      `json:"ContinueOnDeviceEligibleDeviceInfo"`
	Gilligvited                        bool          `json:"gilligvited"`
	AppleIdAliases                     []interface{} `json:"appleIdAliases"`
	UbiquityEOLEnabled                 bool          `json:"ubiquityEOLEnabled"`
	IsPaidDeveloper                    bool          `json:"isPaidDeveloper"`
	CountryCode                        string        `json:"countryCode"`
	NotificationId                     string        `json:"notificationId"`
	PrimaryEmailVerified               bool          `json:"primaryEmailVerified"`
	ADsID                              string        `json:"aDsID"`
	Locked                             bool          `json:"locked"`
	ICDRSCapableDeviceCount            int           `json:"ICDRSCapableDeviceCount"`
	HasICloudQualifyingDevice          bool          `json:"hasICloudQualifyingDevice"`
	PrimaryEmail                       string        `json:"primaryEmail"`
	AppleIdEntries                     []struct {
		IsPrimary bool   `json:"isPrimary"`
		Type      string `json:"type"`
		Value     string `json:"value"`
	} `json:"appleIdEntries"`
	GilliganEnabled    bool   `json:"gilligan-enabled"`
	IsWebAccessAllowed bool   `json:"isWebAccessAllowed"`
	FullName           string `json:"fullName"`
	MailFlags          struct {
		IsThreadingAvailable           bool `json:"isThreadingAvailable"`
		IsSearchV2Provisioned          bool `json:"isSearchV2Provisioned"`
		SCKMail                        bool `json:"sCKMail"`
		IsMppSupportedInCurrentCountry bool `json:"isMppSupportedInCurrentCountry"`
	} `json:"mailFlags"`
	LanguageCode         string `json:"languageCode"`
	AppleId              string `json:"appleId"`
	HasUnreleasedOS      bool   `json:"hasUnreleasedOS"`
	AnalyticsOptInStatus bool   `json:"analyticsOptInStatus"`
	FirstName            string `json:"firstName"`
	ICloudAppleIdAlias   string `json:"iCloudAppleIdAlias"`
	NotesMigrated        bool   `json:"notesMigrated"`
	BeneficiaryInfo      struct {
		IsBeneficiary bool `json:"isBeneficiary"`
	} `json:"beneficiaryInfo"`
	HasPaymentInfo bool   `json:"hasPaymentInfo"`
	PcsDelet       bool   `json:"pcsDelet"`
	AppleIdAlias   string `json:"appleIdAlias"`
	BrMigrated     bool   `json:"brMigrated"`
	StatusCode     int    `json:"statusCode"`
	FamilyEligible bool   `json:"familyEligible"`
}

Jump to

Keyboard shortcuts

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