RSS allow infinite range to extend beyond current season. Closes #800, #3876, #6170.

--HG--
branch : magao-dev
This commit is contained in:
Tim Delaney 2016-11-07 07:18:06 +11:00
parent 96c1187f47
commit 32bdb73f70
2 changed files with 10 additions and 7 deletions

View file

@ -96,6 +96,7 @@ 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(";");
int sOurs = s.toInt();
foreach (const QString &epStr, eps) { foreach (const QString &epStr, eps) {
if (epStr.isEmpty()) if (epStr.isEmpty())
@ -108,8 +109,8 @@ 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 partialPattern1 = "\\bs0?" + s + "[ -_\\.]?" + "e(0?\\d{1,4})(?:\\D|\\b)"; QString partialPattern1 = "\\bs0?(\\d{1,4})[ -_\\.]?e(0?\\d{1,4})(?:\\D|\\b)";
QString partialPattern2 = "\\b" + s + "x" + "(0?\\d{1,4})(?:\\D|\\b)"; QString partialPattern2 = "\\b(\\d{1,4})x(0?\\d{1,4})(?:\\D|\\b)";
QRegExp reg(partialPattern1, Qt::CaseInsensitive); QRegExp reg(partialPattern1, Qt::CaseInsensitive);
if (ep.endsWith('-')) { // Infinite range if (ep.endsWith('-')) { // Infinite range
@ -124,8 +125,9 @@ bool DownloadRule::matches(const QString &articleTitle) const
} }
if (pos != -1) { if (pos != -1) {
int epTheirs = reg.cap(1).toInt(); int sTheirs = reg.cap(1).toInt();
if (epTheirs >= epOurs) { int epTheirs = reg.cap(2).toInt();
if (((sTheirs == sOurs) && (epTheirs >= epOurs)) || (sTheirs > sOurs)) {
qDebug() << "Matched episode:" << ep; qDebug() << "Matched episode:" << ep;
qDebug() << "Matched article:" << articleTitle; qDebug() << "Matched article:" << articleTitle;
return true; return true;
@ -150,8 +152,9 @@ bool DownloadRule::matches(const QString &articleTitle) const
} }
if (pos != -1) { if (pos != -1) {
int epTheirs = reg.cap(1).toInt(); int sTheirs = reg.cap(1).toInt();
if ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs)) { int epTheirs = reg.cap(2).toInt();
if ((sTheirs == sOurs) && ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs))) {
qDebug() << "Matched episode:" << ep; qDebug() << "Matched episode:" << ep;
qDebug() << "Matched article:" << articleTitle; qDebug() << "Matched article:" << articleTitle;
return true; return true;

View file

@ -83,7 +83,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>
+ "<li>" + tr("Three range types for episodes are supported: ") + "</li>" + "<li><ul>" + "<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>" "<li>" + tr("Single number: <b>1x25;</b> matches episode 25 of season one") + "</li>"
+ "<li>" + tr("Normal range: <b>1x25-40;</b> matches episodes 25 through 40 of season one") + "</li>" + "<li>" + tr("Normal range: <b>1x25-40;</b> matches episodes 25 through 40 of season one") + "</li>"
+ "<li>" + tr("Infinite range: <b>1x25-;</b> matches episodes 25 and upward of season one") + "</li>" + "</ul></li></ul>"; + "<li>" + tr("Infinite range: <b>1x25-;</b> matches episodes 25 and upward of season one, and all episodes of later seasons") + "</li>" + "</ul></li></ul>";
ui->lineEFilter->setToolTip(tip); ui->lineEFilter->setToolTip(tip);
initCategoryCombobox(); initCategoryCombobox();
loadFeedList(); loadFeedList();