|
|
@ -90,7 +90,7 @@ func main() {
|
|
|
|
up.Type = input.KeyUp
|
|
|
|
up.Type = input.KeyUp
|
|
|
|
|
|
|
|
|
|
|
|
for _, ev := range []*input.DispatchKeyEventParams{&down, &up} {
|
|
|
|
for _, ev := range []*input.DispatchKeyEventParams{&down, &up} {
|
|
|
|
log.Printf("Event: %+v", *ev)
|
|
|
|
// log.Printf("Event: %+v", *ev)
|
|
|
|
if err := ev.Do(ctx); err != nil {
|
|
|
|
if err := ev.Do(ctx); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -108,7 +108,7 @@ func main() {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
download := func(ctx context.Context, location string) (string, error) {
|
|
|
|
download := func(ctx context.Context, location string, doMarkDone bool) (string, error) {
|
|
|
|
dir := s.dlDir
|
|
|
|
dir := s.dlDir
|
|
|
|
keyD, ok := kb.Keys['D']
|
|
|
|
keyD, ok := kb.Keys['D']
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
@ -131,7 +131,7 @@ func main() {
|
|
|
|
up.Type = input.KeyUp
|
|
|
|
up.Type = input.KeyUp
|
|
|
|
|
|
|
|
|
|
|
|
for _, ev := range []*input.DispatchKeyEventParams{&down, &up} {
|
|
|
|
for _, ev := range []*input.DispatchKeyEventParams{&down, &up} {
|
|
|
|
log.Printf("Event: %+v", *ev)
|
|
|
|
// log.Printf("Event: %+v", *ev)
|
|
|
|
if err := ev.Do(ctx); err != nil {
|
|
|
|
if err := ev.Do(ctx); err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -160,6 +160,9 @@ func main() {
|
|
|
|
if v.IsDir() {
|
|
|
|
if v.IsDir() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.Name() == ".lastdone" {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
fileEntries = append(fileEntries, v.Name())
|
|
|
|
fileEntries = append(fileEntries, v.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(fileEntries) < 1 {
|
|
|
|
if len(fileEntries) < 1 {
|
|
|
@ -181,6 +184,10 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !doMarkDone {
|
|
|
|
|
|
|
|
return filename, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := markDone(dir, location); err != nil {
|
|
|
|
if err := markDone(dir, location); err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -201,18 +208,27 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dlAndMove := func(ctx context.Context, location string) error {
|
|
|
|
dlAndMove := func(ctx context.Context, location string, doMarkDone bool) error {
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
dlFile, err := download(ctx, location)
|
|
|
|
dlFile, err := download(ctx, location, doMarkDone)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mvDl(dlFile)(ctx)
|
|
|
|
return mvDl(dlFile)(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dlAndMoveW := func() func(ctx context.Context) error {
|
|
|
|
|
|
|
|
return func(ctx context.Context) error {
|
|
|
|
|
|
|
|
var location string
|
|
|
|
|
|
|
|
if err := chromedp.Location(&location).Do(ctx); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dlAndMove(ctx, location, false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
firstNav := func(ctx context.Context) error {
|
|
|
|
firstNav := func(ctx context.Context) error {
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
log.Printf("sent key")
|
|
|
|
|
|
|
|
chromedp.Sleep(500 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.Sleep(500 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.KeyEvent("\n").Do(ctx)
|
|
|
|
chromedp.KeyEvent("\n").Do(ctx)
|
|
|
|
chromedp.Sleep(500 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.Sleep(500 * time.Millisecond).Do(ctx)
|
|
|
@ -221,15 +237,13 @@ func main() {
|
|
|
|
|
|
|
|
|
|
|
|
navRight := func(ctx context.Context) error {
|
|
|
|
navRight := func(ctx context.Context) error {
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
log.Printf("sent key")
|
|
|
|
|
|
|
|
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.WaitReady("body", chromedp.ByQuery)
|
|
|
|
chromedp.WaitReady("body", chromedp.ByQuery)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
navLeft := func(ctx context.Context) error {
|
|
|
|
navLeft := func(ctx context.Context) error {
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight).Do(ctx)
|
|
|
|
chromedp.KeyEvent(kb.ArrowLeft).Do(ctx)
|
|
|
|
log.Printf("sent key")
|
|
|
|
|
|
|
|
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.Sleep(5000 * time.Millisecond).Do(ctx)
|
|
|
|
chromedp.WaitReady("body", chromedp.ByQuery)
|
|
|
|
chromedp.WaitReady("body", chromedp.ByQuery)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -274,7 +288,7 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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); err != nil {
|
|
|
|
if err := dlAndMove(ctx, location, true); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n++
|
|
|
|
n++
|
|
|
@ -317,7 +331,7 @@ func main() {
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.KeyEvent(kb.ArrowRight),
|
|
|
|
chromedp.ActionFunc(firstNav),
|
|
|
|
chromedp.ActionFunc(firstNav),
|
|
|
|
chromedp.ActionFunc(dlAndMove),
|
|
|
|
chromedp.ActionFunc(dlAndMoveW()),
|
|
|
|
chromedp.ActionFunc(navN("left", *nItemsFlag-1)),
|
|
|
|
chromedp.ActionFunc(navN("left", *nItemsFlag-1)),
|
|
|
|
); err != nil {
|
|
|
|
); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|