From caff55cf7a6cbca79621de9105b8d81bec416060 Mon Sep 17 00:00:00 2001 From: dtylman Date: Mon, 3 Dec 2018 09:17:26 +0200 Subject: [PATCH] adding page-size flag --- .gitignore | 2 ++ downloader/downloader.go | 4 +++- main.go | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a557dd6..500c3ef 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ credentials.json token.json gitmoo-goog +gitmoo-goog.bz2 +gitmoo-goog.zip diff --git a/downloader/downloader.go b/downloader/downloader.go index 5b984c9..82bc896 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -24,6 +24,8 @@ var Options struct { BackupFolder string //MaxItems how many items to download MaxItems int + //number of items to download on per API call + PageSize int //Throtthle is time to wait between API calls Throttle int //Google photos AlbumID @@ -132,7 +134,7 @@ func DownloadAll(svc *photoslibrary.Service) error { stats.errors = 0 stats.total = 0 stats.totalsize = 0 - req := &photoslibrary.SearchMediaItemsRequest{PageSize: int64(Options.MaxItems), AlbumId: Options.AlbumID} + req := &photoslibrary.SearchMediaItemsRequest{PageSize: int64(Options.PageSize), AlbumId: Options.AlbumID} for hasMore { sleepTime := time.Duration(time.Second * time.Duration(Options.Throttle)) log.Printf("Processed: %v, Downloaded: %v, Errors: %v, Total Size: %v, Waiting %v", stats.total, stats.downloaded, stats.errors, humanize.Bytes(stats.totalsize), sleepTime) diff --git a/main.go b/main.go index 6e7ca5a..1ae02bb 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ import ( ) //Version is the version number -const Version = "0.2" +const Version = "0.21" var options struct { loop bool @@ -121,6 +121,7 @@ func main() { flag.StringVar(&downloader.Options.BackupFolder, "folder", "", "backup folder") flag.StringVar(&downloader.Options.AlbumID, "album", "", "download only from this album (use google album id)") flag.IntVar(&downloader.Options.MaxItems, "max", math.MaxInt32, "max items to download") + flag.IntVar(&downloader.Options.PageSize, "pagesize", 50, "number of items to download on per API call") flag.IntVar(&downloader.Options.Throttle, "throttle", 5, "Time, in seconds, to wait between API calls") flag.Parse()