Parse the author name from content.opf file (#165)

## Summary

* Parse the author name from content.opf file
  * Listed in the dc:creator tag within the metadata section
This commit is contained in:
Dave Allie
2025-12-30 22:15:44 +11:00
committed by GitHub
parent 3dd52f30fa
commit be1b5bad21
4 changed files with 28 additions and 2 deletions
@@ -102,6 +102,11 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name
return;
}
if (self->state == IN_METADATA && strcmp(name, "dc:creator") == 0) {
self->state = IN_BOOK_AUTHOR;
return;
}
if (self->state == IN_PACKAGE && (strcmp(name, "manifest") == 0 || strcmp(name, "opf:manifest") == 0)) {
self->state = IN_MANIFEST;
if (!SdMan.openFileForWrite("COF", self->cachePath + itemCacheFile, self->tempItemStore)) {
@@ -209,6 +214,11 @@ void XMLCALL ContentOpfParser::characterData(void* userData, const XML_Char* s,
self->title.append(s, len);
return;
}
if (self->state == IN_BOOK_AUTHOR) {
self->author.append(s, len);
return;
}
}
void XMLCALL ContentOpfParser::endElement(void* userData, const XML_Char* name) {
@@ -232,6 +242,11 @@ void XMLCALL ContentOpfParser::endElement(void* userData, const XML_Char* name)
return;
}
if (self->state == IN_BOOK_AUTHOR && strcmp(name, "dc:creator") == 0) {
self->state = IN_METADATA;
return;
}
if (self->state == IN_METADATA && (strcmp(name, "metadata") == 0 || strcmp(name, "opf:metadata") == 0)) {
self->state = IN_PACKAGE;
return;