Browse Source

Allow episode zero (special) and leading zeroes in RSS episode filter.

--HG--
branch : magao-dev
adaptive-webui-19844
Tim Delaney 8 years ago
parent
commit
64f9cbbf54
  1. 14
      src/base/rss/rssdownloadrule.cpp
  2. 2
      src/gui/rss/automatedrssdownloader.cpp

14
src/base/rss/rssdownloadrule.cpp

@ -31,6 +31,8 @@ @@ -31,6 +31,8 @@
#include <QRegExp>
#include <QDebug>
#include <QDir>
#include <QStringRef>
#include <QVector>
#include "base/preferences.h"
#include "base/utils/fs.h"
@ -97,10 +99,16 @@ bool DownloadRule::matches(const QString &articleTitle) const @@ -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 @@ -120,7 +128,7 @@ bool DownloadRule::matches(const QString &articleTitle) const
}
}
else { // Normal range
QStringList range = ep.split('-');
QVector<QStringRef> range = ep.split('-');
Q_ASSERT(range.size() == 2);
if (range.first().toInt() > range.last().toInt())
continue; // Ignore this subrule completely

2
src/gui/rss/automatedrssdownloader.cpp

@ -78,7 +78,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager> @@ -78,7 +78,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>
QString tip = "<p>" + tr("Matches articles based on episode filter.") + "</p><p><b>" + tr("Example: ")
+ "1x2;8-15;5;30-;</b>" + tr(" will match 2, 5, 8 through 15, 30 and onward episodes of season one", "example X will match") + "</p>";
tip += "<p>" + tr("Episode filter rules: ") + "</p><ul><li>" + tr("Season number is a mandatory non-zero value") + "</li>"
+ "<li>" + tr("Episode number is a mandatory non-zero value") + "</li>"
+ "<li>" + tr("Episode number is a mandatory positive value") + "</li>"
+ "<li>" + tr("Filter must end with semicolon") + "</li>"
+ "<li>" + tr("Three range types for episodes are supported: ") + "</li>" + "<li><ul>"
"<li>" + tr("Single number: <b>1x25;</b> matches episode 25 of season one") + "</li>"

Loading…
Cancel
Save