Make parsing of chapter timestamps more robust

Solves #19
This commit is contained in:
Bart De Vries 2021-10-13 20:40:22 +02:00
parent 6d164e019b
commit ca595c985c
1 changed files with 9 additions and 2 deletions

View File

@ -276,8 +276,15 @@ bool UpdateFeedJob::processEntry(Syndication::ItemPtr entry)
QDomElement element = nodelist.at(i).toElement();
QString title = element.attribute(QStringLiteral("title"));
QString start = element.attribute(QStringLiteral("start"));
QTime startString = QTime::fromString(start, QStringLiteral("hh:mm:ss.zzz"));
int startInt = startString.hour() * 60 * 60 + startString.minute() * 60 + startString.second();
QStringList startParts = start.split(QStringLiteral(":"));
// Some podcasts use colon for milliseconds as well
while (startParts.count() > 3) {
startParts.removeLast();
}
int startInt = 0;
for (QString part : startParts) {
startInt = part.toInt() + startInt * 60;
}
QString images = element.attribute(QStringLiteral("image"));
processChapter(entry->id(), startInt, title, entry->link(), images);
}