nItemsFlag=flag.Int("n",-1,"number of items to download. If negative, get them all.")
nItemsFlag=flag.Int("n",-1,"number of items to download. If negative, get them all.")
devFlag=flag.Bool("dev",false,"dev mode. we reuse the same session dir (/tmp/gphotos-cdp), so we don't have to auth at every run.")
devFlag=flag.Bool("dev",false,"dev mode. we reuse the same session dir (/tmp/gphotos-cdp), so we don't have to auth at every run.")
dlDirFlag=flag.String("dldir","","where to (temporarily) write the downloads. defaults to $HOME/Downloads/gphotos-cdp.")
dlDirFlag=flag.String("dldir","","where to write the downloads. defaults to $HOME/Downloads/gphotos-cdp.")
startFlag=flag.String("start","","skip all photos until this location is reached. for debugging.")
startFlag=flag.String("start","","skip all photos until this location is reached. for debugging.")
runFlag=flag.String("run","","the program to run on each downloaded item, right after it is dowloaded. It is also the responsibility of that program to remove the downloaded item, if desired.")
runFlag=flag.String("run","","the program to run on each downloaded item, right after it is dowloaded. It is also the responsibility of that program to remove the downloaded item, if desired.")
verboseFlag=flag.Bool("v",false,"be verbose")
verboseFlag=flag.Bool("v",false,"be verbose")
@ -86,11 +86,16 @@ func main() {
typeSessionstruct{
typeSessionstruct{
parentContextcontext.Context
parentContextcontext.Context
parentCancelcontext.CancelFunc
parentCancelcontext.CancelFunc
dlDirstring
dlDirstring// dir where the photos get stored
profileDirstring
profileDirstring// user data session dir. automatically created on chrome startup.
lastDonestring
// lastDone is the most recent (wrt to Google Photos timeline) item (its URL
// really) that was downloaded. If set, it is used as a sentinel, to indicate that
// we should skip dowloading all items older than this one.
lastDonestring
}
}
// getLastDone returns the URL of the most recent item that was downloaded in
// the previous run. If any, it should have been stored in dlDir/.lastdone