Browse Source

Merge pull request #9595 from elFarto/master

Allow to disable downloading REPACK/PROPER matches
adaptive-webui-19844
Vladimir Golovnev 6 years ago committed by GitHub
parent
commit
85d49e2540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/base/rss/rss_autodownloader.cpp
  2. 3
      src/base/rss/rss_autodownloader.h
  3. 2
      src/base/rss/rss_autodownloadrule.cpp
  4. 3
      src/gui/optionsdialog.cpp
  5. 16
      src/gui/optionsdialog.ui

11
src/base/rss/rss_autodownloader.cpp

@ -66,6 +66,7 @@ const QString RulesFileName(QStringLiteral("download_rules.json")); @@ -66,6 +66,7 @@ const QString RulesFileName(QStringLiteral("download_rules.json"));
const QString SettingsKey_ProcessingEnabled(QStringLiteral("RSS/AutoDownloader/EnableProcessing"));
const QString SettingsKey_SmartEpisodeFilter(QStringLiteral("RSS/AutoDownloader/SmartEpisodeFilter"));
const QString SettingsKey_DownloadRepacks(QStringLiteral("RSS/AutoDownloader/DownloadRepacks"));
namespace
{
@ -310,6 +311,16 @@ void AutoDownloader::setSmartEpisodeFilters(const QStringList &filters) @@ -310,6 +311,16 @@ void AutoDownloader::setSmartEpisodeFilters(const QStringList &filters)
m_smartEpisodeRegex.setPattern(regex);
}
bool AutoDownloader::downloadRepacks() const
{
return SettingsStorage::instance()->loadValue(SettingsKey_DownloadRepacks, true).toBool();
}
void AutoDownloader::setDownloadRepacks(const bool downloadRepacks)
{
SettingsStorage::instance()->storeValue(SettingsKey_DownloadRepacks, downloadRepacks);
}
void AutoDownloader::process()
{
if (m_processingQueue.isEmpty()) return; // processing was disabled

3
src/base/rss/rss_autodownloader.h

@ -85,6 +85,9 @@ namespace RSS @@ -85,6 +85,9 @@ namespace RSS
void setSmartEpisodeFilters(const QStringList &filters);
QRegularExpression smartEpisodeRegex() const;
bool downloadRepacks() const;
void setDownloadRepacks(bool downloadRepacks);
bool hasRule(const QString &ruleName) const;
AutoDownloadRule ruleByName(const QString &ruleName) const;
QList<AutoDownloadRule> rules() const;

2
src/base/rss/rss_autodownloadrule.cpp

@ -344,7 +344,7 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) co @@ -344,7 +344,7 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) co
// See if this episode has been downloaded before
const bool previouslyMatched = m_dataPtr->previouslyMatchedEpisodes.contains(episodeStr);
const bool isRepack = articleTitle.contains("REPACK", Qt::CaseInsensitive) || articleTitle.contains("PROPER", Qt::CaseInsensitive);
if (previouslyMatched && !isRepack)
if (previouslyMatched && (!isRepack || !AutoDownloader::instance()->downloadRepacks()))
return false;
m_dataPtr->lastComputedEpisode = episodeStr;

3
src/gui/optionsdialog.cpp

@ -407,6 +407,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -407,6 +407,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->checkRSSEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
connect(m_ui->checkRSSAutoDownloaderEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
connect(m_ui->textSmartEpisodeFilters, &QPlainTextEdit::textChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->checkSmartFilterDownloadRepacks, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
connect(m_ui->spinRSSRefreshInterval, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->spinRSSMaxArticlesPerFeed, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
@ -593,6 +594,7 @@ void OptionsDialog::saveOptions() @@ -593,6 +594,7 @@ void OptionsDialog::saveOptions()
RSS::Session::instance()->setProcessingEnabled(m_ui->checkRSSEnable->isChecked());
RSS::AutoDownloader::instance()->setProcessingEnabled(m_ui->checkRSSAutoDownloaderEnable->isChecked());
RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', QString::SplitBehavior::SkipEmptyParts));
RSS::AutoDownloader::instance()->setDownloadRepacks(m_ui->checkSmartFilterDownloadRepacks->isChecked());
auto session = BitTorrent::Session::instance();
@ -829,6 +831,7 @@ void OptionsDialog::loadOptions() @@ -829,6 +831,7 @@ void OptionsDialog::loadOptions()
m_ui->checkRSSEnable->setChecked(RSS::Session::instance()->isProcessingEnabled());
m_ui->checkRSSAutoDownloaderEnable->setChecked(RSS::AutoDownloader::instance()->isProcessingEnabled());
m_ui->textSmartEpisodeFilters->setPlainText(RSS::AutoDownloader::instance()->smartEpisodeFilters().join('\n'));
m_ui->checkSmartFilterDownloadRepacks->setChecked(RSS::AutoDownloader::instance()->downloadRepacks());
m_ui->spinRSSRefreshInterval->setValue(RSS::Session::instance()->refreshInterval());
m_ui->spinRSSMaxArticlesPerFeed->setValue(RSS::Session::instance()->maxArticlesPerFeed());

16
src/gui/optionsdialog.ui

@ -2833,9 +2833,23 @@ @@ -2833,9 +2833,23 @@
<item>
<widget class="QGroupBox" name="groupRSSSmartEpisodeFilter">
<property name="title">
<string>RSS Smart Episode Filters</string>
<string>RSS Smart Episode Filter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
<item>
<widget class="QCheckBox" name="checkSmartFilterDownloadRepacks">
<property name="text">
<string>Download REPACK/PROPER episodes</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filters:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="textSmartEpisodeFilters"/>
</item>

Loading…
Cancel
Save