Skip to content

Commit

Permalink
adding vendor, album id filter
Browse files Browse the repository at this point in the history
  • Loading branch information
dtylman committed Dec 3, 2018
1 parent a68bb98 commit e91899f
Show file tree
Hide file tree
Showing 200 changed files with 70,758 additions and 3 deletions.
4 changes: 3 additions & 1 deletion downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var Options struct {
MaxItems int
//Throtthle is time to wait between API calls
Throttle int
//Google photos AlbumID
AlbumID string
}

var stats struct {
Expand Down Expand Up @@ -130,7 +132,7 @@ func DownloadAll(svc *photoslibrary.Service) error {
stats.errors = 0
stats.total = 0
stats.totalsize = 0
req := &photoslibrary.SearchMediaItemsRequest{PageSize: 50}
req := &photoslibrary.SearchMediaItemsRequest{PageSize: int64(Options.MaxItems), 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)
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"
"os"

"github.com/dtylman/photos/downloader"
"github.com/dtylman/gitmoo-goog/downloader"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
Expand All @@ -19,7 +19,7 @@ import (
)

//Version is the version number
const Version = "0.1"
const Version = "0.2"

var options struct {
loop bool
Expand Down Expand Up @@ -119,8 +119,10 @@ func main() {
flag.BoolVar(&options.ignoreerrors, "force", false, "ignore errors, and force working")
flag.StringVar(&options.logfile, "logfile", "", "log to this file")
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.Throttle, "throttle", 5, "Time, in seconds, to wait between API calls")

flag.Parse()
if options.logfile != "" {
log.SetOutput(&lumberjack.Logger{
Expand Down
202 changes: 202 additions & 0 deletions vendor/cloud.google.com/go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e91899f

Please sign in to comment.