summaryrefslogtreecommitdiff
path: root/cmd/iiifdownloader
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-06-23 13:51:02 +0100
committerNick White <git@njw.name>2020-06-23 13:51:02 +0100
commit6464846d1e6ee9c339f71abca1a2284051ad22ac (patch)
tree509e749bdc4ad9993e5b072a1d842ff0f2356e06 /cmd/iiifdownloader
parentb0808416cc830aef680f5b6f99a616d425cbb9de (diff)
[iiifdownloader] Add support for BNF urls with a dot after book id
Diffstat (limited to 'cmd/iiifdownloader')
-rw-r--r--cmd/iiifdownloader/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/iiifdownloader/main.go b/cmd/iiifdownloader/main.go
index 03a15bc..f6ad6ca 100644
--- a/cmd/iiifdownloader/main.go
+++ b/cmd/iiifdownloader/main.go
@@ -15,6 +15,9 @@ import (
const usage = `Usage: iiifdownloader url
Downloads all pages from a IIIF server.
+
+Currently supports the following IIIF using services:
+- BNF's Gallica (any book or page URL should work)
`
const bnfPrefix = `https://gallica.bnf.fr/ark:/`
@@ -73,8 +76,15 @@ func main() {
if len(f) < 2 {
log.Fatalln("Failed to extract BNF book ID from URL")
}
- bookid := f[0] + "/" + f[1]
- bookdir = f[0] + "-" + f[1]
+ var lastpart string
+ dot := strings.Index(f[1], ".")
+ if dot == -1 {
+ lastpart = f[1]
+ } else {
+ lastpart = f[1][0:dot]
+ }
+ bookid := f[0] + "/" + lastpart
+ bookdir = f[0] + "-" + lastpart
pgurlStart = "https://gallica.bnf.fr/iiif/ark:/" + bookid + "/f"
pgurlEnd = "/full/full/0/native.jpg"