qBittorrent
rss_autodownloadrule.cpp File Reference
#include "rss_autodownloadrule.h"
#include <algorithm>
#include <QDebug>
#include <QHash>
#include <QJsonArray>
#include <QJsonObject>
#include <QRegularExpression>
#include <QSharedData>
#include <QString>
#include <QStringList>
#include "base/global.h"
#include "base/preferences.h"
#include "base/utils/fs.h"
#include "base/utils/string.h"
#include "rss_article.h"
#include "rss_autodownloader.h"
#include "rss_feed.h"
Include dependency graph for rss_autodownloadrule.cpp:

Go to the source code of this file.

Classes

struct  RSS::AutoDownloadRuleData
 

Namespaces

 anonymous_namespace{rss_autodownloadrule.cpp}
 
 RSS
 

Functions

std::optional< bool > anonymous_namespace{rss_autodownloadrule.cpp}::toOptionalBool (const QJsonValue &jsonVal)
 
QJsonValue anonymous_namespace{rss_autodownloadrule.cpp}::toJsonValue (const std::optional< bool > boolValue)
 
std::optional< bool > anonymous_namespace{rss_autodownloadrule.cpp}::addPausedLegacyToOptionalBool (const int val)
 
int anonymous_namespace{rss_autodownloadrule.cpp}::toAddPausedLegacy (const std::optional< bool > boolValue)
 
std::optional< BitTorrent::TorrentContentLayoutanonymous_namespace{rss_autodownloadrule.cpp}::jsonValueToContentLayout (const QJsonValue &jsonVal)
 
QJsonValue anonymous_namespace{rss_autodownloadrule.cpp}::contentLayoutToJsonValue (const std::optional< BitTorrent::TorrentContentLayout > contentLayout)
 
const QString Str_Name (QStringLiteral("name"))
 
const QString Str_Enabled (QStringLiteral("enabled"))
 
const QString Str_UseRegex (QStringLiteral("useRegex"))
 
const QString Str_MustContain (QStringLiteral("mustContain"))
 
const QString Str_MustNotContain (QStringLiteral("mustNotContain"))
 
const QString Str_EpisodeFilter (QStringLiteral("episodeFilter"))
 
const QString Str_AffectedFeeds (QStringLiteral("affectedFeeds"))
 
const QString Str_SavePath (QStringLiteral("savePath"))
 
const QString Str_AssignedCategory (QStringLiteral("assignedCategory"))
 
const QString Str_LastMatch (QStringLiteral("lastMatch"))
 
const QString Str_IgnoreDays (QStringLiteral("ignoreDays"))
 
const QString Str_AddPaused (QStringLiteral("addPaused"))
 
const QString Str_CreateSubfolder (QStringLiteral("createSubfolder"))
 
const QString Str_ContentLayout (QStringLiteral("torrentContentLayout"))
 
const QString Str_SmartFilter (QStringLiteral("smartFilter"))
 
const QString Str_PreviouslyMatched (QStringLiteral("previouslyMatchedEpisodes"))
 
QString computeEpisodeName (const QString &article)
 

Function Documentation

◆ computeEpisodeName()

QString computeEpisodeName ( const QString &  article)

Definition at line 168 of file rss_autodownloadrule.cpp.

169 {
170  const QRegularExpression episodeRegex = AutoDownloader::instance()->smartEpisodeRegex();
171  const QRegularExpressionMatch match = episodeRegex.match(article);
172 
173  // See if we can extract an season/episode number or date from the title
174  if (!match.hasMatch())
175  return {};
176 
177  QStringList ret;
178  for (int i = 1; i <= match.lastCapturedIndex(); ++i)
179  {
180  const QString cap = match.captured(i);
181 
182  if (cap.isEmpty())
183  continue;
184 
185  bool isInt = false;
186  const int x = cap.toInt(&isInt);
187 
188  ret.append(isInt ? QString::number(x) : cap);
189  }
190  return ret.join('x');
191 }

References RSS::AutoDownloader::instance(), and RSS::AutoDownloader::smartEpisodeRegex().

Referenced by RSS::AutoDownloadRule::matchesSmartEpisodeFilter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Str_AddPaused()

const QString Str_AddPaused ( QStringLiteral("addPaused")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_AffectedFeeds()

const QString Str_AffectedFeeds ( QStringLiteral("affectedFeeds")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_AssignedCategory()

const QString Str_AssignedCategory ( QStringLiteral("assignedCategory")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_ContentLayout()

const QString Str_ContentLayout ( QStringLiteral("torrentContentLayout")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_CreateSubfolder()

const QString Str_CreateSubfolder ( QStringLiteral("createSubfolder")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject().

Here is the caller graph for this function:

◆ Str_Enabled()

const QString Str_Enabled ( QStringLiteral("enabled")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_EpisodeFilter()

const QString Str_EpisodeFilter ( QStringLiteral("episodeFilter")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_IgnoreDays()

const QString Str_IgnoreDays ( QStringLiteral("ignoreDays")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_LastMatch()

const QString Str_LastMatch ( QStringLiteral("lastMatch")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_MustContain()

const QString Str_MustContain ( QStringLiteral("mustContain")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_MustNotContain()

const QString Str_MustNotContain ( QStringLiteral("mustNotContain")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_Name()

const QString Str_Name ( QStringLiteral("name")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject().

Here is the caller graph for this function:

◆ Str_PreviouslyMatched()

const QString Str_PreviouslyMatched ( QStringLiteral("previouslyMatchedEpisodes")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_SavePath()

const QString Str_SavePath ( QStringLiteral("savePath")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_SmartFilter()

const QString Str_SmartFilter ( QStringLiteral("smartFilter")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ Str_UseRegex()

const QString Str_UseRegex ( QStringLiteral("useRegex")  )

Referenced by RSS::AutoDownloadRule::fromJsonObject(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function: