multiple attachments in attachments zoteroItem

This commit is contained in:
Marcell Mars 2022-04-28 13:36:05 +02:00
parent 3a505ce022
commit 55777c078a
1 changed files with 15 additions and 9 deletions

View File

@ -103,16 +103,21 @@ should be enough for the next successful build).`,
attachmentsQuery := bibliographyNode.FindElements("[name()='link:link']")
itemAttachments := zoteroUnion.CreateElement("attachments")
mimeTypeMap := make(map[string]bool)
for _, attachment := range attachmentsQuery {
attachmentID := attachment.SelectAttr("rdf:resource").Value
zAttachment := root.FindElement(fmt.Sprintf("[@rdf:about='%s']", attachmentID))
mimeType := zAttachment.FindElement("[name()='link:type']").Text()
if mimeType != "text/html" {
itemAttachment := itemAttachments.CreateElement("attachment")
attachmentsIDs[attachmentID] = true
filePath := zAttachment.FindElement("[name()='rdf:resource']").SelectAttr("rdf:resource").Value
itemAttachment.CreateElement("path").SetText(filePath)
itemAttachment.CreateElement("mimeType").SetText(mimeType)
if !mimeTypeMap[mimeType] {
attachmentsIDs[attachmentID] = true
filePath := zAttachment.FindElement("[name()='rdf:resource']").SelectAttr("rdf:resource").Value
itemAttachments.CreateElement("attachment").CreateElement("path").SetText(filePath)
itemAttachments.CreateElement("attachment").CreateElement("mimeType").SetText(mimeType)
mimeTypeMap[mimeType] = true
} else {
fmt.Println("DUPLICATE mimeType:", mimeType, attachmentID)
}
}
}
@ -206,8 +211,9 @@ should be enough for the next successful build).`,
}
zi, _ := xml.MarshalIndent(zoteroItem, " ", " ")
os.Stdout.Write(zi)
fmt.Println("\n~ ~ ~ ~ ~ ~")
_ = zi
// os.Stdout.Write(zi)
// fmt.Println("\n~+~ ~ ~ ~ ~")
// fmt.Printf("\nZoteroItem: %#v\n", zoteroItem)
bookOpf.Version = "2.0"
@ -227,8 +233,8 @@ should be enough for the next successful build).`,
log.Fatalln(err)
}
_ = bookOpfOutput
//os.Stdout.Write(bookOpfOutput)
//fmt.Println("\n ~ ~ ~ ~ ~")
// os.Stdout.Write(bookOpfOutput)
// fmt.Println("\n ~ ~ ~ ~ ~")
}
calibre.RenderStandaloneApp(calibrePath, librarianName, libraryUUID, librarySecret, jsonPath)
},