summaryrefslogtreecommitdiff
path: root/getabook.c
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2012-07-13 20:00:09 +0100
committerNick White <git@njw.me.uk>2012-07-13 20:00:09 +0100
commitb426cacb2ef7d14a41d91ffbf3676a4275d02bb3 (patch)
treec1311cb2f52eecf3e6479d7b1af6568991f59abf /getabook.c
parent2778403ae4a7fca968fb8f09cabcab2bbc83b998 (diff)
Allow non-amazon hosted images in getabook now that they're using cloudfront
Diffstat (limited to 'getabook.c')
-rw-r--r--getabook.c11
1 files 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;
}