simplify jumping to last done

pull/2/merge
mpl 5 years ago
parent d3e2f47461
commit 29e5c7216c

@ -237,12 +237,19 @@ func main() {
}
firstNav := func(ctx context.Context) error {
// TODO(mpl): do these two special cases even before jumping to the oldest.
if *startFlag != "" {
chromedp.Navigate(*startFlag).Do(ctx)
chromedp.WaitReady("body", chromedp.ByQuery).Do(ctx)
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
return nil
}
if s.lastDone != "" {
chromedp.Navigate(s.lastDone).Do(ctx)
chromedp.WaitReady("body", chromedp.ByQuery).Do(ctx)
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
return nil
}
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
chromedp.Sleep(500 * time.Millisecond).Do(ctx)
chromedp.KeyEvent("\n").Do(ctx)
@ -274,27 +281,16 @@ func main() {
return nil
}
var location string
// TODO(mpl): navigate directly to lastdone.
lookingForLastDone := true
if s.lastDone == "" {
lookingForLastDone = false
}
for {
// TODO(mpl): move the Location call to within download() ?
if err := chromedp.Location(&location).Do(ctx); err != nil {
return err
}
if !lookingForLastDone {
// TODO(mpl): deal with getting the very last photo to properly exit that loop when N < 0.
if err := dlAndMove(ctx, location, true); err != nil {
return err
}
n++
} else {
println(location, " ALREADY DONE")
if location == s.lastDone {
lookingForLastDone = false
}
// TODO(mpl): deal with getting the very last photo to properly exit that loop when N < 0.
if err := dlAndMove(ctx, location, true); err != nil {
return err
}
n++
if N > 0 && n >= N {
break
}

Loading…
Cancel
Save