mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-16 22:27:42 +03:00
Parse cover image path from content.opf file (#24)
Some checks are pending
CI / build (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
This commit is contained in:
parent
449b3ca161
commit
c262f222de
@ -69,6 +69,9 @@ bool Epub::parseContentOpf(const std::string& contentOpfFilePath) {
|
|||||||
|
|
||||||
// Grab data from opfParser into epub
|
// Grab data from opfParser into epub
|
||||||
title = opfParser.title;
|
title = opfParser.title;
|
||||||
|
if (!opfParser.coverItemId.empty() && opfParser.items.count(opfParser.coverItemId) > 0) {
|
||||||
|
coverImageItem = opfParser.items.at(opfParser.coverItemId);
|
||||||
|
}
|
||||||
|
|
||||||
if (opfParser.items.count("ncx")) {
|
if (opfParser.items.count("ncx")) {
|
||||||
tocNcxItem = opfParser.items.at("ncx");
|
tocNcxItem = opfParser.items.at("ncx");
|
||||||
|
|||||||
@ -90,9 +90,23 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Support book cover
|
if (self->state == IN_METADATA && (strcmp(name, "meta") == 0 || strcmp(name, "opf:meta") == 0)) {
|
||||||
// if (self->state == IN_METADATA && (strcmp(name, "meta") == 0 || strcmp(name, "opf:meta") == 0)) {
|
bool isCover = false;
|
||||||
// }
|
std::string coverItemId;
|
||||||
|
|
||||||
|
for (int i = 0; atts[i]; i += 2) {
|
||||||
|
if (strcmp(atts[i], "name") == 0 && strcmp(atts[i + 1], "cover") == 0) {
|
||||||
|
isCover = true;
|
||||||
|
} else if (strcmp(atts[i], "content") == 0) {
|
||||||
|
coverItemId = atts[i + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCover) {
|
||||||
|
self->coverItemId = coverItemId;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (self->state == IN_MANIFEST && (strcmp(name, "item") == 0 || strcmp(name, "opf:item") == 0)) {
|
if (self->state == IN_MANIFEST && (strcmp(name, "item") == 0 || strcmp(name, "opf:item") == 0)) {
|
||||||
std::string itemId;
|
std::string itemId;
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class ContentOpfParser final : public Print {
|
|||||||
public:
|
public:
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string tocNcxPath;
|
std::string tocNcxPath;
|
||||||
|
std::string coverItemId;
|
||||||
std::map<std::string, std::string> items;
|
std::map<std::string, std::string> items;
|
||||||
std::vector<std::string> spineRefs;
|
std::vector<std::string> spineRefs;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user