mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Merge pull request #9988 from elFarto/master
Keep track of REPACK/PROPER downloads
This commit is contained in:
commit
38f4bea6f1
@ -126,7 +126,7 @@ namespace RSS
|
|||||||
bool smartFilter = false;
|
bool smartFilter = false;
|
||||||
QStringList previouslyMatchedEpisodes;
|
QStringList previouslyMatchedEpisodes;
|
||||||
|
|
||||||
mutable QString lastComputedEpisode;
|
mutable QStringList lastComputedEpisodes;
|
||||||
mutable QHash<QString, QRegularExpression> cachedRegexes;
|
mutable QHash<QString, QRegularExpression> cachedRegexes;
|
||||||
|
|
||||||
bool operator==(const AutoDownloadRuleData &other) const
|
bool operator==(const AutoDownloadRuleData &other) const
|
||||||
@ -265,7 +265,7 @@ bool AutoDownloadRule::matchesMustNotContainExpression(const QString &articleTit
|
|||||||
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitle) const
|
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitle) const
|
||||||
{
|
{
|
||||||
// Reset the lastComputedEpisode, we don't want to leak it between matches
|
// Reset the lastComputedEpisode, we don't want to leak it between matches
|
||||||
m_dataPtr->lastComputedEpisode.clear();
|
m_dataPtr->lastComputedEpisodes.clear();
|
||||||
|
|
||||||
if (m_dataPtr->episodeFilter.isEmpty())
|
if (m_dataPtr->episodeFilter.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
@ -343,11 +343,35 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) co
|
|||||||
|
|
||||||
// See if this episode has been downloaded before
|
// See if this episode has been downloaded before
|
||||||
const bool previouslyMatched = m_dataPtr->previouslyMatchedEpisodes.contains(episodeStr);
|
const bool previouslyMatched = m_dataPtr->previouslyMatchedEpisodes.contains(episodeStr);
|
||||||
const bool isRepack = articleTitle.contains("REPACK", Qt::CaseInsensitive) || articleTitle.contains("PROPER", Qt::CaseInsensitive);
|
if (previouslyMatched) {
|
||||||
if (previouslyMatched && (!isRepack || !AutoDownloader::instance()->downloadRepacks()))
|
if (!AutoDownloader::instance()->downloadRepacks())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_dataPtr->lastComputedEpisode = episodeStr;
|
// Now see if we've downloaded this particular repack/proper combination
|
||||||
|
const bool isRepack = articleTitle.contains("REPACK", Qt::CaseInsensitive);
|
||||||
|
const bool isProper = articleTitle.contains("PROPER", Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
if (!isRepack && !isProper)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QString fullEpisodeStr = QString("%1%2%3").arg(episodeStr,
|
||||||
|
isRepack ? "-REPACK" : "",
|
||||||
|
isProper ? "-PROPER" : "");
|
||||||
|
const bool previouslyMatchedFull = m_dataPtr->previouslyMatchedEpisodes.contains(fullEpisodeStr);
|
||||||
|
if (previouslyMatchedFull)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_dataPtr->lastComputedEpisodes.append(fullEpisodeStr);
|
||||||
|
|
||||||
|
// If this is a REPACK and PROPER download, add the individual entries to the list
|
||||||
|
// so we don't download those
|
||||||
|
if (isRepack && isProper) {
|
||||||
|
m_dataPtr->lastComputedEpisodes.append(QString("%1-REPACK").arg(episodeStr));
|
||||||
|
m_dataPtr->lastComputedEpisodes.append(QString("%1-PROPER").arg(episodeStr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dataPtr->lastComputedEpisodes.append(episodeStr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,10 +403,10 @@ bool AutoDownloadRule::accepts(const QVariantHash &articleData)
|
|||||||
|
|
||||||
setLastMatch(articleData[Article::KeyDate].toDateTime());
|
setLastMatch(articleData[Article::KeyDate].toDateTime());
|
||||||
|
|
||||||
if (!m_dataPtr->lastComputedEpisode.isEmpty()) {
|
// If there's a matched episode string, add that to the previously matched list
|
||||||
// TODO: probably need to add a marker for PROPER/REPACK to avoid duplicate downloads
|
if (!m_dataPtr->lastComputedEpisodes.isEmpty()) {
|
||||||
m_dataPtr->previouslyMatchedEpisodes.append(m_dataPtr->lastComputedEpisode);
|
m_dataPtr->previouslyMatchedEpisodes.append(m_dataPtr->lastComputedEpisodes);
|
||||||
m_dataPtr->lastComputedEpisode.clear();
|
m_dataPtr->lastComputedEpisodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user