summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-24 12:40:13 +0100
committerNick White <hg@njw.me.uk>2011-07-24 12:40:13 +0100
commitca9116d685f375ba91be47c3c60b66853a95cb4a (patch)
treef94cb756b56b58cf9118e3e59928c941ca0520e5
parentbd2fd4f1007508298660d1b617b9368280ed9f51 (diff)
Fix little bugs
-rw-r--r--getgbook.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/getgbook.c b/getgbook.c
index 08cee6c..ecd34a6 100644
--- a/getgbook.c
+++ b/getgbook.c
@@ -49,7 +49,8 @@ Page *getpagedetail(char *bookid, char *pg, char *cookie)
*p = *d;
}
*p = '\0';
- }
+ } else
+ d=c;
for(; *d; d++) {
if(*d == '}') {
@@ -106,20 +107,29 @@ int main(int argc, char *argv[])
}
continue;
}
+ retry=0;
if(argv[1][1] == 'a') {
- snprintf(n, 80, "%05d.png", page->num);
+ if(page->num != -1)
+ snprintf(n, 80, "%05d.png", page->num);
+ else
+ snprintf(n, 80, "%s.png", page->name);
gettofile("books.google.com", page->url, cookie, NULL, n);
printf("Downloaded page %d\n", page->num);
- } else if(page->num != -1)
- printf("%s %d\n", page->name, page->num);
+ } else {
+ printf("%s ", page->name);
+ if(page->num != -1) printf("%d", page->num);
+ printf("\n");
+ }
free(page);
}
} else {
while(fgets(buf, 1024, stdin)) {
sscanf(buf, "%15s", pg);
+ snprintf(u, URLMAX, "/books?id=%s", bookid);
+ get("books.google.com", u, NULL, cookie, &tmp);
if(!(page = getpagedetail(bookid, pg, cookie)) || !page->url[0]) {
fprintf(stderr, "%s failed\n", pg);
- free(page);
+ if(page) free(page);
continue;
}
snprintf(n, 80, "%05d.png", page->num);