diff options
author | Nick White <git@njw.me.uk> | 2012-07-13 20:01:55 +0100 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2012-07-13 20:01:55 +0100 |
commit | 212213c11531456ab1b4f270e4a5cd9cecba74f6 (patch) | |
tree | 9341f292874be3fe642cc13ece396313f9765f0e /getabook.c | |
parent | b426cacb2ef7d14a41d91ffbf3676a4275d02bb3 (diff) |
Try first 25 pages even if they aren't indexed with getabook
Diffstat (limited to 'getabook.c')
-rw-r--r-- | getabook.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -68,7 +68,7 @@ int getpagelist() char b[STRMAX] = ""; char *buf = NULL; char *s, *c; - int i; + int i, n, found; Page *p; snprintf(url, URLMAX, "/gp/search-inside/service-data?method=getBookData&asin=%s", bookid); @@ -103,6 +103,22 @@ int getpagelist() fillurls(buf); free(buf); + + /* ensure first 25 pages are included, as sometimes they work + * even if not listed. */ + for(i=0; i<25 && i<MAXPAGES; i++) { + found = 0; + for(n=0; n<numpages; n++) { + if(pages[n]->num == i) + found = 1; + } + if(!found) { + p=pages[numpages++]=malloc(sizeof(**pages));; + p->num = i; + p->url[0] = '\0'; + } + } + return 0; } @@ -139,7 +155,7 @@ int getpage(Page *page) fprintf(stderr, "can't parse host of %s\n", page->url); return 1; } - + if(gettofile(host, page->url, NULL, NULL, path, 0)) { fprintf(stderr, "%d failed\n", page->num); return 1; |