handle end of gallery properly

pull/2/merge
mpl 5 years ago
parent 74c9cf9c02
commit a2e303781b

@ -28,6 +28,9 @@ var (
runFlag = flag.String("run", "", "the program to run on each downloaded item, right after it is dowloaded. It is also the responsibility of that program to remove the downloaded item, if desired.") runFlag = flag.String("run", "", "the program to run on each downloaded item, right after it is dowloaded. It is also the responsibility of that program to remove the downloaded item, if desired.")
) )
// TODO(mpl): in general everywhere, do not rely so much on sleeps. We need
// better ways to wait for things to be loaded/ready.
func main() { func main() {
flag.Parse() flag.Parse()
if *nItemsFlag == 0 { if *nItemsFlag == 0 {
@ -114,7 +117,6 @@ func main() {
if err := chromedp.Location(&location).Do(ctx); err != nil { if err := chromedp.Location(&location).Do(ctx); err != nil {
return err return err
} }
println(location, " VS ", prevLocation)
if location == prevLocation { if location == prevLocation {
break break
} }
@ -280,12 +282,16 @@ func main() {
if N == 0 { if N == 0 {
return nil return nil
} }
var location string var location, prevLocation string
for { for {
if err := chromedp.Location(&location).Do(ctx); err != nil { if err := chromedp.Location(&location).Do(ctx); err != nil {
return err return err
} }
// TODO(mpl): deal with getting the very last photo to properly exit that loop when N < 0. if location == prevLocation {
break
}
prevLocation = location
filePath, err := dlAndMove(ctx, location) filePath, err := dlAndMove(ctx, location)
if err != nil { if err != nil {
return err return err

Loading…
Cancel
Save