mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Update the XML parser to parse the new supported fields
This commit is contained in:
parent
f2bf53ce5b
commit
e9ce6fc5af
@ -1,5 +1,7 @@
|
|||||||
#include "xml_info_parser.h"
|
#include "xml_info_parser.h"
|
||||||
|
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
bool isValidText(const QString &string)
|
bool isValidText(const QString &string)
|
||||||
@ -65,6 +67,7 @@ void consolidateDate(ComicInfo &info)
|
|||||||
bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
|
bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
|
||||||
{
|
{
|
||||||
std::map<QString, QVariant &> stringValues = {
|
std::map<QString, QVariant &> stringValues = {
|
||||||
|
{ "Number", info.number },
|
||||||
{ "Title", info.title },
|
{ "Title", info.title },
|
||||||
{ "Volume", info.volume },
|
{ "Volume", info.volume },
|
||||||
{ "StoryArc", info.storyArc },
|
{ "StoryArc", info.storyArc },
|
||||||
@ -74,16 +77,23 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
|
|||||||
{ "AgeRating", info.ageRating },
|
{ "AgeRating", info.ageRating },
|
||||||
{ "Summary", info.synopsis },
|
{ "Summary", info.synopsis },
|
||||||
{ "Notes", info.notes },
|
{ "Notes", info.notes },
|
||||||
|
{ "Editor", info.editor },
|
||||||
|
{ "Imprint", info.imprint },
|
||||||
|
{ "Series", info.series },
|
||||||
|
{ "AlternateSeries", info.alternateSeries },
|
||||||
|
{ "AlternateNumber", info.alternateNumber },
|
||||||
|
{ "LanguageISO", info.languageISO },
|
||||||
|
{ "SeriesGroup", info.seriesGroup },
|
||||||
|
{ "MainCharacterOrTeam", info.mainCharacterOrTeam },
|
||||||
|
{ "Review", info.review },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<QString, QVariant &> forcedNumbers = {
|
std::map<QString, QVariant &> forcedNumbers = {
|
||||||
{ "Number", info.number },
|
|
||||||
{ "Count", info.count },
|
{ "Count", info.count },
|
||||||
{ "AlternateNumber", info.arcNumber },
|
{ "AlternateCount", info.alternateCount },
|
||||||
{ "AlternateCount", info.arcCount },
|
|
||||||
{ "Day", info.day },
|
{ "Day", info.day },
|
||||||
{ "Month", info.month },
|
{ "Month", info.month },
|
||||||
{ "Year", info.year }
|
{ "Year", info.year },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<QString, QVariant &> multiValuedStrings = {
|
std::map<QString, QVariant &> multiValuedStrings = {
|
||||||
@ -93,7 +103,9 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
|
|||||||
{ "Colorist", info.colorist },
|
{ "Colorist", info.colorist },
|
||||||
{ "Letterer", info.letterer },
|
{ "Letterer", info.letterer },
|
||||||
{ "CoverArtist", info.coverArtist },
|
{ "CoverArtist", info.coverArtist },
|
||||||
{ "Characters", info.characters }
|
{ "Characters", info.characters },
|
||||||
|
{ "Teams", info.teams },
|
||||||
|
{ "Locations", info.locations }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto &pair : stringValues) {
|
for (auto &pair : stringValues) {
|
||||||
@ -130,16 +142,17 @@ bool tryValues(QXmlStreamReader &reader, ComicInfo &info)
|
|||||||
if (reader.name() == QString("Manga")) {
|
if (reader.name() == QString("Manga")) {
|
||||||
auto string = reader.readElementText();
|
auto string = reader.readElementText();
|
||||||
if (isValidText(string)) {
|
if (isValidText(string)) {
|
||||||
if (string == "Yes" || string == "YesAndRightToLeft") {
|
if (string == "Yes" || string == "YesAndRightToLeft") { // there was a breaking change in ComicInfo 2.0, Yes means now WesterManga reading style, but old info stills means manga
|
||||||
info.manga = true;
|
info.type = QVariant::fromValue(YACReader::FileType::Manga);
|
||||||
} else if (string == "No") {
|
} else if (string == "No") {
|
||||||
info.manga = false;
|
info.type = QVariant::fromValue(YACReader::FileType::Comic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO, check if the url is actually a comic vine link
|
||||||
if (reader.name() == QString("Web")) {
|
if (reader.name() == QString("Web")) {
|
||||||
auto string = reader.readElementText();
|
auto string = reader.readElementText();
|
||||||
if (isValidText(string)) {
|
if (isValidText(string)) {
|
||||||
@ -166,7 +179,7 @@ bool YACReader::parseXMLIntoInfo(const QByteArray &xmlRawData, ComicInfo &info)
|
|||||||
|
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
if (tryValues(reader, info)) {
|
if (tryValues(reader, info)) {
|
||||||
someDataWasParsed = true;
|
someDataWasParsed = true | someDataWasParsed;
|
||||||
} else {
|
} else {
|
||||||
if (reader.name() != QString("ComicInfo")) {
|
if (reader.name() != QString("ComicInfo")) {
|
||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
|
Loading…
Reference in New Issue
Block a user