|
|
@ -96,8 +96,6 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
|
|
|
|
|
|
|
|
QString s = f.cap(1); |
|
|
|
QString s = f.cap(1); |
|
|
|
QStringList eps = f.cap(2).split(";"); |
|
|
|
QStringList eps = f.cap(2).split(";"); |
|
|
|
QString expStr; |
|
|
|
|
|
|
|
expStr += "s0?" + s + "[ -_\\.]?" + "e0?"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (const QString &epStr, eps) { |
|
|
|
foreach (const QString &epStr, eps) { |
|
|
|
if (epStr.isEmpty()) |
|
|
|
if (epStr.isEmpty()) |
|
|
@ -110,14 +108,21 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
ep = ep.right(ep.size() - 1); |
|
|
|
ep = ep.right(ep.size() - 1); |
|
|
|
|
|
|
|
|
|
|
|
if (ep.indexOf('-') != -1) { // Range detected
|
|
|
|
if (ep.indexOf('-') != -1) { // Range detected
|
|
|
|
QString partialPattern = "s0?" + s + "[ -_\\.]?" + "e(0?\\d{1,4})"; |
|
|
|
QString partialPattern1 = "\\bs0?" + s + "[ -_\\.]?" + "e(0?\\d{1,4})(?:\\D|\\b)"; |
|
|
|
QRegExp reg(partialPattern, Qt::CaseInsensitive); |
|
|
|
QString partialPattern2 = "\\b" + s + "x" + "(0?\\d{1,4})(?:\\D|\\b)"; |
|
|
|
|
|
|
|
QRegExp reg(partialPattern1, Qt::CaseInsensitive); |
|
|
|
|
|
|
|
|
|
|
|
if (ep.endsWith('-')) { // Infinite range
|
|
|
|
if (ep.endsWith('-')) { // Infinite range
|
|
|
|
int epOurs = ep.left(ep.size() - 1).toInt(); |
|
|
|
int epOurs = ep.left(ep.size() - 1).toInt(); |
|
|
|
|
|
|
|
|
|
|
|
// Extract partial match from article and compare as digits
|
|
|
|
// Extract partial match from article and compare as digits
|
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pos == -1) { |
|
|
|
|
|
|
|
reg = QRegExp(partialPattern2, Qt::CaseInsensitive); |
|
|
|
|
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (pos != -1) { |
|
|
|
if (pos != -1) { |
|
|
|
int epTheirs = reg.cap(1).toInt(); |
|
|
|
int epTheirs = reg.cap(1).toInt(); |
|
|
|
if (epTheirs >= epOurs) { |
|
|
|
if (epTheirs >= epOurs) { |
|
|
@ -138,6 +143,12 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
|
|
|
|
|
|
|
|
// Extract partial match from article and compare as digits
|
|
|
|
// Extract partial match from article and compare as digits
|
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pos == -1) { |
|
|
|
|
|
|
|
reg = QRegExp(partialPattern2, Qt::CaseInsensitive); |
|
|
|
|
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (pos != -1) { |
|
|
|
if (pos != -1) { |
|
|
|
int epTheirs = reg.cap(1).toInt(); |
|
|
|
int epTheirs = reg.cap(1).toInt(); |
|
|
|
if ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs)) { |
|
|
|
if ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs)) { |
|
|
@ -149,7 +160,8 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { // Single number
|
|
|
|
else { // Single number
|
|
|
|
QRegExp reg(expStr + ep + "\\D", Qt::CaseInsensitive); |
|
|
|
QString expStr("\\b(?:s0?" + s + "[ -_\\.]?" + "e0?" + ep + "|" + s + "x" + "0?" + ep + ")(?:\\D|\\b)"); |
|
|
|
|
|
|
|
QRegExp reg(expStr, Qt::CaseInsensitive); |
|
|
|
if (reg.indexIn(articleTitle) != -1) { |
|
|
|
if (reg.indexIn(articleTitle) != -1) { |
|
|
|
qDebug() << "Matched episode:" << ep; |
|
|
|
qDebug() << "Matched episode:" << ep; |
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|