The Gphotos type manages a browser instance and a web server to facilitate photo downloads.
New() (*Gphotos, error)
Initializes a new Gphotos instance, starts the browser, and starts the web server. It checks if the user is already authenticated by navigating to the Google Photos URL.
Download(photoID string) (string, error)
Downloads a specific photo using its ID.
- Mechanism: It opens a new browser tab, navigates to the photo URL (
https://photos.google.com/lr/photo/{photoID}), waits for the network response, and simulates a Shift+D keypress to trigger the high-resolution download. - Concurrency: Only one download can occur at a time due to internal locking.
- Returns: The local file path to the downloaded photo. This file is intended to be temporary and should be deleted after use.
// Example of calling the Download method
path, err := g.Download("YOUR_PHOTO_ID")
if err != nil {
log.Fatal(err)
}
// Use path, then delete it