diff options
author | Nick White <hg@njw.me.uk> | 2011-07-29 01:03:44 +0100 |
---|---|---|
committer | Nick White <hg@njw.me.uk> | 2011-07-29 01:03:44 +0100 |
commit | 5945770938a14d2364ab56049df4988cb25890d9 (patch) | |
tree | 05262709ce9414b7979170b7062b89a5efbd68f5 /getgbook.c | |
parent | 568751040761f707deeb46b7032912ac7a7dd34b (diff) |
Retry properly with specific pages
Diffstat (limited to 'getgbook.c')
-rw-r--r-- | getgbook.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -124,16 +124,19 @@ int main(int argc, char *argv[]) } else { while(fgets(buf, 1024, stdin)) { sscanf(buf, "%15s", pg); - get("books.google.com", "/", NULL, cookie, &tmp); - if(!(page = getpagedetail(bookid, pg, cookie)) || !page->url[0]) { - fprintf(stderr, "%s failed\n", pg); + for(retry = 0; retry < 5; retry++) { + get("books.google.com", "/", NULL, cookie, &tmp); + if((page = getpagedetail(bookid, pg, cookie)) && page->url[0]) { + snprintf(n, 80, "%05d.png", page->num); + gettofile("books.google.com", page->url, cookie, NULL, n); + printf("Downloaded page %d\n", page->num); + free(page); + break; + } if(page) free(page); - continue; } - snprintf(n, 80, "%05d.png", page->num); - gettofile("books.google.com", page->url, cookie, NULL, n); - printf("Downloaded page %d\n", page->num); - free(page); + if(retry == 5) + fprintf(stderr, "%s failed\n", pg); } } |