|
|
@ -50,26 +50,45 @@ DownloadRule::DownloadRule() |
|
|
|
|
|
|
|
|
|
|
|
bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (const QString &token, m_mustContain) { |
|
|
|
if (!m_mustContain.empty()) { |
|
|
|
if (!token.isEmpty()) { |
|
|
|
bool logged = false; |
|
|
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard); |
|
|
|
|
|
|
|
if (reg.indexIn(articleTitle) < 0) |
|
|
|
foreach (const QString &token, m_mustContain) { |
|
|
|
return false; |
|
|
|
if (!token.isEmpty()) { |
|
|
|
|
|
|
|
if (!logged) { |
|
|
|
|
|
|
|
qDebug() << "Checking matching expressions:" << m_mustContain.join("|"); |
|
|
|
|
|
|
|
logged = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard); |
|
|
|
|
|
|
|
if (reg.indexIn(articleTitle) < 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
qDebug("Checking not matching tokens"); |
|
|
|
|
|
|
|
// Checking not matching
|
|
|
|
if (!m_mustNotContain.empty()) { |
|
|
|
foreach (const QString &token, m_mustNotContain) { |
|
|
|
bool logged = false; |
|
|
|
if (!token.isEmpty()) { |
|
|
|
|
|
|
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard); |
|
|
|
foreach (const QString &token, m_mustNotContain) { |
|
|
|
if (reg.indexIn(articleTitle) > -1) |
|
|
|
if (!token.isEmpty()) { |
|
|
|
return false; |
|
|
|
if (!logged) { |
|
|
|
|
|
|
|
qDebug() << "Checking not matching expressions:" << m_mustNotContain.join("|"); |
|
|
|
|
|
|
|
logged = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard); |
|
|
|
|
|
|
|
if (reg.indexIn(articleTitle) > -1) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!m_episodeFilter.isEmpty()) { |
|
|
|
if (!m_episodeFilter.isEmpty()) { |
|
|
|
qDebug("Checking episode filter"); |
|
|
|
qDebug() << "Checking episode filter:" << m_episodeFilter; |
|
|
|
QRegExp f("(^\\d{1,4})x(.*;$)"); |
|
|
|
QRegExp f("(^\\d{1,4})x(.*;$)"); |
|
|
|
int pos = f.indexIn(m_episodeFilter); |
|
|
|
int pos = f.indexIn(m_episodeFilter); |
|
|
|
|
|
|
|
|
|
|
|
if (pos < 0) |
|
|
|
if (pos < 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
@ -93,8 +112,11 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
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) { |
|
|
|
|
|
|
|
qDebug() << "Matched episode:" << ep; |
|
|
|
|
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { // Normal range
|
|
|
|
else { // Normal range
|
|
|
@ -110,19 +132,28 @@ bool DownloadRule::matches(const QString &articleTitle) const |
|
|
|
pos = reg.indexIn(articleTitle); |
|
|
|
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)) { |
|
|
|
|
|
|
|
qDebug() << "Matched episode:" << ep; |
|
|
|
|
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { // Single number
|
|
|
|
else { // Single number
|
|
|
|
QRegExp reg(expStr + ep + "\\D", Qt::CaseInsensitive); |
|
|
|
QRegExp reg(expStr + ep + "\\D", Qt::CaseInsensitive); |
|
|
|
if (reg.indexIn(articleTitle) != -1) |
|
|
|
if (reg.indexIn(articleTitle) != -1) { |
|
|
|
|
|
|
|
qDebug() << "Matched episode:" << ep; |
|
|
|
|
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Matched article:" << articleTitle; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -302,6 +333,7 @@ QStringList DownloadRule::findMatchingArticles(const FeedPtr &feed) const |
|
|
|
ArticleHash::ConstIterator artItend = feedArticles.end(); |
|
|
|
ArticleHash::ConstIterator artItend = feedArticles.end(); |
|
|
|
for (; artIt != artItend; ++artIt) { |
|
|
|
for (; artIt != artItend; ++artIt) { |
|
|
|
const QString title = artIt.value()->title(); |
|
|
|
const QString title = artIt.value()->title(); |
|
|
|
|
|
|
|
qDebug() << "Matching article:" << title; |
|
|
|
if (matches(title)) |
|
|
|
if (matches(title)) |
|
|
|
ret << title; |
|
|
|
ret << title; |
|
|
|
} |
|
|
|
} |
|
|
|