From f495ecbddcf5f5ad884c0510363411b4460c77bd Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 16 Jul 2011 16:33:21 +0100 Subject: Add basic page turning --- getgbook.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'getgbook.c') diff --git a/getgbook.c b/getgbook.c index de600d8..fa69db9 100644 --- a/getgbook.c +++ b/getgbook.c @@ -104,7 +104,7 @@ char *getpageurl(char *bookid, char *pg) int main(int argc, char *argv[]) { char *bookid, *url, pg[16]; - int totalpages; + int totalpages, i; if(argc < 2 || argc > 3) die(usage); @@ -118,15 +118,22 @@ int main(int argc, char *argv[]) if(!(totalpages = gettotalpages(bookid))) die("Book has no pages\n"); - printf("Book has %d pages\n", totalpages); - - strncpy(pg, "PA2", 12); - if((url = getpageurl(bookid, pg)) == NULL) - fprintf(stderr, "Could not find page %s\n", pg); - else { - strncat(pg, ".png", 16); - gettofile(url, pg); - printf("Downloaded page %s\n", pg); + + /* note this isn't the best way, not least because it misses the + * non PA pages. best is to crawl around the json grabbing everything + * available, by starting on PP1, and filling in by going through + * all pages in totalpages. then crawl through the pages struct. */ + for(i=1; i