summaryrefslogtreecommitdiff
path: root/cmd/iiifdownloader/main.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-09-08 17:07:14 +0100
committerNick White <git@njw.name>2020-09-08 17:07:14 +0100
commit03451211b60c0b6a6601fa3a27dc48c2cf79e878 (patch)
treec1af3e3ef7638cd1055a267c0a89ab32a01c266d /cmd/iiifdownloader/main.go
parentd7ee70939b2a05f2aea68234d70dc8c591abad58 (diff)
Add the option to force METS usage for BSB
Diffstat (limited to 'cmd/iiifdownloader/main.go')
-rw-r--r--cmd/iiifdownloader/main.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd/iiifdownloader/main.go b/cmd/iiifdownloader/main.go
index b6a51f9..15ac66a 100644
--- a/cmd/iiifdownloader/main.go
+++ b/cmd/iiifdownloader/main.go
@@ -16,7 +16,7 @@ import (
"strings"
)
-const usage = `Usage: iiifdownloader url
+const usage = `Usage: iiifdownloader [-mets] url
Downloads all pages from a IIIF server.
@@ -24,6 +24,7 @@ Currently supports the following IIIF using services:
- BNF's Gallica example url: https://gallica.bnf.fr/ark:/12148/bpt6k6468158v
- BSB / MDZ example url: https://reader.digitale-sammlungen.de//de/fs1/object/display/bsb10132387_00005.html
- DFG Viewer example url: http://dfg-viewer.de/show?set%%5Bmets%%5D=http%%3A%%2F%%2Fdaten.digitale-sammlungen.de%%2F~db%%2Fmets%%2Fbsb11274872_mets.xml&cHash=fd18451ee968c125ab2bdbfd3717eae6
+
`
const bnfPrefix = `https://gallica.bnf.fr/ark:/`
@@ -164,6 +165,9 @@ func urlToPgName(u string) string {
b := path.Base(u)
if b != "default.jpg" && b != "native.jpg" {
+ if path.Ext(b) == "" {
+ return b + ".jpg"
+ }
return b
}
@@ -299,6 +303,7 @@ func sanitiseUrl(u string) string {
}
func main() {
+ forcemets := flag.Bool("mets", false, "Force METS metadata to be used (BSB / MDZ only)")
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), usage)
flag.PrintDefaults()
@@ -352,9 +357,14 @@ func main() {
bookdir = bookid
iiifurl := "https://api.digitale-sammlungen.de/iiif/presentation/v2/" + bookid + "/manifest"
- pgUrls, err = parseIIIFManifest(iiifurl)
+ if *forcemets {
+ iiifurl = "https://daten.digitale-sammlungen.de/~db/mets/" + bookid + "_mets.xml"
+ pgUrls, err = parseMets(iiifurl)
+ } else {
+ pgUrls, err = parseIIIFManifest(iiifurl)
+ }
if err != nil {
- log.Fatalf("Error parsing IIIF manifest url %s: %v\n", iiifurl, err)
+ log.Fatalf("Error parsing manifest url %s: %v\n", iiifurl, err)
}
case strings.HasPrefix(u, dfgPrefix):
// dfg can have a url encoded mets url in several parts of the viewer url