|
|
@ -31,6 +31,8 @@ |
|
|
|
#include <QRegExp> |
|
|
|
#include <QRegExp> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDir> |
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
#include <QStringRef> |
|
|
|
|
|
|
|
#include <QVector> |
|
|
|
|
|
|
|
|
|
|
|
#include "base/preferences.h" |
|
|
|
#include "base/preferences.h" |
|
|
|
#include "base/utils/fs.h" |
|
|
|
#include "base/utils/fs.h" |
|
|
@ -97,10 +99,16 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
QString expStr; |
|
|
|
QString expStr; |
|
|
|
expStr += "s0?" + s + "[ -_\\.]?" + "e0?"; |
|
|
|
expStr += "s0?" + s + "[ -_\\.]?" + "e0?"; |
|
|
|
|
|
|
|
|
|
|
|
foreach (const QString &ep, eps) { |
|
|
|
foreach (const QString &epStr, eps) { |
|
|
|
if (ep.isEmpty()) |
|
|
|
if (epStr.isEmpty()) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStringRef ep( &epStr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We need to trim leading zeroes, but if it's all zeros then we want episode zero.
|
|
|
|
|
|
|
|
while (ep.size() > 1 && ep.startsWith("0")) |
|
|
|
|
|
|
|
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 partialPattern = "s0?" + s + "[ -_\\.]?" + "e(0?\\d{1,4})"; |
|
|
|
QRegExp reg(partialPattern, Qt::CaseInsensitive); |
|
|
|
QRegExp reg(partialPattern, Qt::CaseInsensitive); |
|
|
@ -120,7 +128,7 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { // Normal range
|
|
|
|
else { // Normal range
|
|
|
|
QStringList range = ep.split('-'); |
|
|
|
QVector<QStringRef> range = ep.split('-'); |
|
|
|
Q_ASSERT(range.size() == 2); |
|
|
|
Q_ASSERT(range.size() == 2); |
|
|
|
if (range.first().toInt() > range.last().toInt()) |
|
|
|
if (range.first().toInt() > range.last().toInt()) |
|
|
|
continue; // Ignore this subrule completely
|
|
|
|
continue; // Ignore this subrule completely
|
|
|
|