mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-26 01:38:20 +03:00
Make "Ignoring days" to behave like other filters
This prevents confusing in GUI when it shows matched RSS articles which be really ignored by the rule.
This commit is contained in:
parent
dedec10c58
commit
007aa8480e
4 changed files with 28 additions and 26 deletions
|
@ -365,19 +365,7 @@ void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
|
||||||
for (AutoDownloadRule &rule: m_rules) {
|
for (AutoDownloadRule &rule: m_rules) {
|
||||||
if (!rule.isEnabled()) continue;
|
if (!rule.isEnabled()) continue;
|
||||||
if (!rule.feedURLs().contains(job->feedURL)) continue;
|
if (!rule.feedURLs().contains(job->feedURL)) continue;
|
||||||
if (!rule.matches(job->articleData.value(Article::KeyTitle).toString())) continue;
|
if (!rule.accepts(job->articleData)) continue;
|
||||||
|
|
||||||
auto articleDate = job->articleData.value(Article::KeyDate).toDateTime();
|
|
||||||
// if rule is in ignoring state do nothing with matched torrent
|
|
||||||
if (rule.ignoreDays() > 0) {
|
|
||||||
if (rule.lastMatch().isValid()) {
|
|
||||||
if (articleDate < rule.lastMatch().addDays(rule.ignoreDays()))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rule.setLastMatch(articleDate);
|
|
||||||
rule.appendLastComputedEpisode();
|
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
storeDeferred();
|
storeDeferred();
|
||||||
|
|
|
@ -351,8 +351,15 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) co
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoDownloadRule::matches(const QString &articleTitle) const
|
bool AutoDownloadRule::matches(const QVariantHash &articleData) const
|
||||||
{
|
{
|
||||||
|
const QDateTime articleDate {articleData[Article::KeyDate].toDateTime()};
|
||||||
|
if (ignoreDays() > 0) {
|
||||||
|
if (lastMatch().isValid() && (articleDate < lastMatch().addDays(ignoreDays())))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString articleTitle {articleData[Article::KeyTitle].toString()};
|
||||||
if (!matchesMustContainExpression(articleTitle))
|
if (!matchesMustContainExpression(articleTitle))
|
||||||
return false;
|
return false;
|
||||||
if (!matchesMustNotContainExpression(articleTitle))
|
if (!matchesMustNotContainExpression(articleTitle))
|
||||||
|
@ -365,6 +372,20 @@ bool AutoDownloadRule::matches(const QString &articleTitle) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AutoDownloadRule::accepts(const QVariantHash &articleData)
|
||||||
|
{
|
||||||
|
if (!matches(articleData))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setLastMatch(articleData[Article::KeyDate].toDateTime());
|
||||||
|
|
||||||
|
if (!m_dataPtr->lastComputedEpisode.isEmpty()) {
|
||||||
|
// TODO: probably need to add a marker for PROPER/REPACK to avoid duplicate downloads
|
||||||
|
m_dataPtr->previouslyMatchedEpisodes.append(m_dataPtr->lastComputedEpisode);
|
||||||
|
m_dataPtr->lastComputedEpisode.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AutoDownloadRule &AutoDownloadRule::operator=(const AutoDownloadRule &other)
|
AutoDownloadRule &AutoDownloadRule::operator=(const AutoDownloadRule &other)
|
||||||
{
|
{
|
||||||
m_dataPtr = other.m_dataPtr;
|
m_dataPtr = other.m_dataPtr;
|
||||||
|
@ -621,15 +642,6 @@ void AutoDownloadRule::setPreviouslyMatchedEpisodes(const QStringList &previousl
|
||||||
m_dataPtr->previouslyMatchedEpisodes = previouslyMatchedEpisodes;
|
m_dataPtr->previouslyMatchedEpisodes = previouslyMatchedEpisodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::appendLastComputedEpisode()
|
|
||||||
{
|
|
||||||
if (!m_dataPtr->lastComputedEpisode.isEmpty()) {
|
|
||||||
// TODO: probably need to add a marker for PROPER/REPACK to avoid duplicate downloads
|
|
||||||
m_dataPtr->previouslyMatchedEpisodes.append(m_dataPtr->lastComputedEpisode);
|
|
||||||
m_dataPtr->lastComputedEpisode.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AutoDownloadRule::episodeFilter() const
|
QString AutoDownloadRule::episodeFilter() const
|
||||||
{
|
{
|
||||||
return m_dataPtr->episodeFilter;
|
return m_dataPtr->episodeFilter;
|
||||||
|
|
|
@ -71,7 +71,6 @@ namespace RSS
|
||||||
QString episodeFilter() const;
|
QString episodeFilter() const;
|
||||||
void setEpisodeFilter(const QString &e);
|
void setEpisodeFilter(const QString &e);
|
||||||
|
|
||||||
void appendLastComputedEpisode();
|
|
||||||
QStringList previouslyMatchedEpisodes() const;
|
QStringList previouslyMatchedEpisodes() const;
|
||||||
void setPreviouslyMatchedEpisodes(const QStringList &previouslyMatchedEpisodes);
|
void setPreviouslyMatchedEpisodes(const QStringList &previouslyMatchedEpisodes);
|
||||||
|
|
||||||
|
@ -82,7 +81,8 @@ namespace RSS
|
||||||
QString assignedCategory() const;
|
QString assignedCategory() const;
|
||||||
void setCategory(const QString &category);
|
void setCategory(const QString &category);
|
||||||
|
|
||||||
bool matches(const QString &articleTitle) const;
|
bool matches(const QVariantHash &articleData) const;
|
||||||
|
bool accepts(const QVariantHash &articleData);
|
||||||
|
|
||||||
AutoDownloadRule &operator=(const AutoDownloadRule &other);
|
AutoDownloadRule &operator=(const AutoDownloadRule &other);
|
||||||
bool operator==(const AutoDownloadRule &other) const;
|
bool operator==(const AutoDownloadRule &other) const;
|
||||||
|
|
|
@ -114,6 +114,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
|
||||||
connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustLineValidity);
|
connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustLineValidity);
|
||||||
connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustNotLineValidity);
|
connect(m_ui->checkRegex, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::updateMustNotLineValidity);
|
||||||
connect(m_ui->checkSmart, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::handleRuleDefinitionChanged);
|
connect(m_ui->checkSmart, &QCheckBox::stateChanged, this, &AutomatedRssDownloader::handleRuleDefinitionChanged);
|
||||||
|
connect(m_ui->spinIgnorePeriod, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
|
||||||
|
, this, &AutomatedRssDownloader::handleRuleDefinitionChanged);
|
||||||
|
|
||||||
connect(m_ui->listFeeds, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleFeedCheckStateChange);
|
connect(m_ui->listFeeds, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleFeedCheckStateChange);
|
||||||
|
|
||||||
|
@ -581,7 +583,7 @@ void AutomatedRssDownloader::updateMatchingArticles()
|
||||||
|
|
||||||
QStringList matchingArticles;
|
QStringList matchingArticles;
|
||||||
foreach (auto article, feed->articles())
|
foreach (auto article, feed->articles())
|
||||||
if (rule.matches(article->title()))
|
if (rule.matches(article->data()))
|
||||||
matchingArticles << article->title();
|
matchingArticles << article->title();
|
||||||
if (!matchingArticles.isEmpty())
|
if (!matchingArticles.isEmpty())
|
||||||
addFeedArticlesToTree(feed, matchingArticles);
|
addFeedArticlesToTree(feed, matchingArticles);
|
||||||
|
|
Loading…
Reference in a new issue