diff --git a/src/base/rss/rssdownloadrule.cpp b/src/base/rss/rssdownloadrule.cpp index 288a7f1fc..819ead7b4 100644 --- a/src/base/rss/rssdownloadrule.cpp +++ b/src/base/rss/rssdownloadrule.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "base/preferences.h" #include "base/utils/fs.h" @@ -97,10 +99,16 @@ bool DownloadRule::matches(const QString &articleTitle) const QString expStr; expStr += "s0?" + s + "[ -_\\.]?" + "e0?"; - foreach (const QString &ep, eps) { - if (ep.isEmpty()) + foreach (const QString &epStr, eps) { + if (epStr.isEmpty()) 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 QString partialPattern = "s0?" + s + "[ -_\\.]?" + "e(0?\\d{1,4})"; QRegExp reg(partialPattern, Qt::CaseInsensitive); @@ -120,7 +128,7 @@ bool DownloadRule::matches(const QString &articleTitle) const } } else { // Normal range - QStringList range = ep.split('-'); + QVector range = ep.split('-'); Q_ASSERT(range.size() == 2); if (range.first().toInt() > range.last().toInt()) continue; // Ignore this subrule completely diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index cd253f849..91d234654 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -78,7 +78,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer QString tip = "

" + tr("Matches articles based on episode filter.") + "

" + tr("Example: ") + "1x2;8-15;5;30-;" + tr(" will match 2, 5, 8 through 15, 30 and onward episodes of season one", "example X will match") + "

"; tip += "

" + tr("Episode filter rules: ") + "

  • " + tr("Season number is a mandatory non-zero value") + "
  • " - + "
  • " + tr("Episode number is a mandatory non-zero value") + "
  • " + + "
  • " + tr("Episode number is a mandatory positive value") + "
  • " + "
  • " + tr("Filter must end with semicolon") + "
  • " + "
  • " + tr("Three range types for episodes are supported: ") + "
  • " + "
    • " "
    • " + tr("Single number: 1x25; matches episode 25 of season one") + "
    • "