From b426cacb2ef7d14a41d91ffbf3676a4275d02bb3 Mon Sep 17 00:00:00 2001 From: Nick White Date: Fri, 13 Jul 2012 20:00:09 +0100 Subject: Allow non-amazon hosted images in getabook now that they're using cloudfront --- getabook.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/getabook.c b/getabook.c index 8892394..78cd511 100644 --- a/getabook.c +++ b/getabook.c @@ -55,7 +55,7 @@ int fillurls(char *buf) { continue; c += strlen(m); - if(!sscanf(c, "\"//sitb-images.amazon.com%[^\"]\"", pages[i]->url)) + if(!sscanf(c, "\"%[^\"]\"", pages[i]->url)) continue; } @@ -126,6 +126,8 @@ int getpageurls(int pagenum) { int getpage(Page *page) { char path[STRMAX]; + char host[STRMAX]; + snprintf(path, STRMAX, "%s/%04d.png", bookdir, page->num); if(page->url[0] == '\0') { @@ -133,7 +135,12 @@ int getpage(Page *page) return 1; } - if(gettofile("sitb-images.amazon.com", page->url, NULL, NULL, path, 0)) { + if(!sscanf(page->url, "http://%[^/]/", host)) { + 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; } -- cgit v1.2.3