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

Loading…
Cancel
Save