|
|
@ -210,9 +210,20 @@ func main() {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
navRightN := func(N int) func(context.Context) error {
|
|
|
|
navLeft := func(ctx context.Context) error {
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
|
|
|
|
log.Printf("sent key")
|
|
|
|
|
|
|
|
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
|
|
|
|
|
|
|
|
chromedp.WaitReady("body", chromedp.ByQuery)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
navN := func(direction string, N int) func(context.Context) error {
|
|
|
|
n := 0
|
|
|
|
n := 0
|
|
|
|
return func(ctx context.Context) error {
|
|
|
|
return func(ctx context.Context) error {
|
|
|
|
|
|
|
|
if direction != "left" && direction != "right" {
|
|
|
|
|
|
|
|
return errors.New("wrong direction, pun intended")
|
|
|
|
|
|
|
|
}
|
|
|
|
if N == 0 {
|
|
|
|
if N == 0 {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -220,8 +231,14 @@ func main() {
|
|
|
|
if N > 0 && n >= N {
|
|
|
|
if N > 0 && n >= N {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := navRight(ctx); err != nil {
|
|
|
|
if direction == "right" {
|
|
|
|
return err
|
|
|
|
if err := navRight(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if err := navLeft(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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); err != nil {
|
|
|
|
if err := dlAndMove(ctx); err != nil {
|
|
|
@ -244,13 +261,31 @@ func main() {
|
|
|
|
log.Printf("body is ready")
|
|
|
|
log.Printf("body is ready")
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
|
|
|
|
// For some reason, I need to do a pagedown before, for the end key to work...
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.PageDown),
|
|
|
|
|
|
|
|
chromedp.Sleep(500*time.Millisecond),
|
|
|
|
chromedp.KeyEvent(kb.End),
|
|
|
|
chromedp.KeyEvent(kb.End),
|
|
|
|
chromedp.Sleep(10000*time.Millisecond),
|
|
|
|
chromedp.Sleep(5000*time.Millisecond),
|
|
|
|
/*
|
|
|
|
// TODO(mpl): do it the smart(er) way: nav right in photo view until the URL does not change anymore. Or something.
|
|
|
|
chromedp.ActionFunc(firstNav),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.ActionFunc(dlAndMove),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.ActionFunc(navRightN(*nItemsFlag-1)),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
*/
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
|
|
|
|
chromedp.ActionFunc(firstNav),
|
|
|
|
|
|
|
|
chromedp.ActionFunc(dlAndMove),
|
|
|
|
|
|
|
|
chromedp.ActionFunc(navN("left", *nItemsFlag-1)),
|
|
|
|
); err != nil {
|
|
|
|
); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -260,7 +295,7 @@ func main() {
|
|
|
|
// https://github.com/chromedp/chromedp/issues/400
|
|
|
|
// https://github.com/chromedp/chromedp/issues/400
|
|
|
|
// https://godoc.org/github.com/chromedp/chromedp/kb
|
|
|
|
// https://godoc.org/github.com/chromedp/chromedp/kb
|
|
|
|
|
|
|
|
|
|
|
|
_, _ = firstNav, navRightN
|
|
|
|
_ = firstNav
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|