mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-06 03:44:29 +00:00
Make sure new RSS download rules apply to existing articles as well, not just new ones
May be related to #116.
This commit is contained in:
parent
7e57a63ec5
commit
819dcacae0
@ -761,6 +761,8 @@ void RSSImp::on_rssDownloaderBtn_clicked()
|
|||||||
{
|
{
|
||||||
AutomatedRssDownloader dlg(m_rssManager, this);
|
AutomatedRssDownloader dlg(m_rssManager, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
if (dlg.isRssDownloaderEnabled())
|
if (dlg.isRssDownloaderEnabled()) {
|
||||||
|
m_rssManager->recheckRssItemsForDownload();
|
||||||
refreshAllFeeds();
|
refreshAllFeeds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,9 @@ const QString& RssArticle::link() const {
|
|||||||
return m_link;
|
return m_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& RssArticle::description() const {
|
QString RssArticle::description() const
|
||||||
if (m_description.isNull())
|
{
|
||||||
return "";
|
return m_description.isNull() ? "" : m_description;
|
||||||
return m_description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDateTime& RssArticle::date() const {
|
const QDateTime& RssArticle::date() const {
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
const QString& author() const;
|
const QString& author() const;
|
||||||
const QString& torrentUrl() const;
|
const QString& torrentUrl() const;
|
||||||
const QString& link() const;
|
const QString& link() const;
|
||||||
const QString& description() const;
|
QString description() const;
|
||||||
const QDateTime& date() const;
|
const QDateTime& date() const;
|
||||||
bool isRead() const;
|
bool isRead() const;
|
||||||
// Setters
|
// Setters
|
||||||
|
@ -313,6 +313,34 @@ void RssFeed::handleFeedTitle(const QString& feedUrl, const QString& title)
|
|||||||
m_manager->forwardFeedInfosChanged(feedUrl, title, m_unreadCount);
|
m_manager->forwardFeedInfosChanged(feedUrl, title, m_unreadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RssFeed::downloadArticleTorrentIfMatching(RssDownloadRuleList* rules, const RssArticlePtr& article)
|
||||||
|
{
|
||||||
|
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
||||||
|
RssDownloadRulePtr matching_rule = rules->findMatchingRule(m_url, article->title());
|
||||||
|
if (!matching_rule)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Torrent was downloaded, consider article as read
|
||||||
|
article->markAsRead();
|
||||||
|
// Download the torrent
|
||||||
|
const QString& torrent_url = article->torrentUrl();
|
||||||
|
QBtSession::instance()->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(article->title()).arg(displayName()));
|
||||||
|
if (torrent_url.startsWith("magnet:", Qt::CaseInsensitive))
|
||||||
|
QBtSession::instance()->addMagnetSkipAddDlg(torrent_url, matching_rule->savePath(), matching_rule->label());
|
||||||
|
else
|
||||||
|
QBtSession::instance()->downloadUrlAndSkipDialog(torrent_url, matching_rule->savePath(), matching_rule->label());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RssFeed::recheckRssItemsForDownload()
|
||||||
|
{
|
||||||
|
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
||||||
|
RssDownloadRuleList* rules = m_manager->downloadRules();
|
||||||
|
foreach (const RssArticlePtr& article, m_articlesByDate) {
|
||||||
|
if (!article->isRead())
|
||||||
|
downloadArticleTorrentIfMatching(rules, article);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RssFeed::handleNewArticle(const QString& feedUrl, const QVariantHash& articleData)
|
void RssFeed::handleNewArticle(const QString& feedUrl, const QVariantHash& articleData)
|
||||||
{
|
{
|
||||||
if (feedUrl != m_url)
|
if (feedUrl != m_url)
|
||||||
@ -329,20 +357,8 @@ void RssFeed::handleNewArticle(const QString& feedUrl, const QVariantHash& artic
|
|||||||
addArticle(article);
|
addArticle(article);
|
||||||
|
|
||||||
// Download torrent if necessary.
|
// Download torrent if necessary.
|
||||||
if (RssSettings().isRssDownloadingEnabled()) {
|
if (RssSettings().isRssDownloadingEnabled())
|
||||||
RssDownloadRulePtr matching_rule = m_manager->downloadRules()->findMatchingRule(m_url, article->title());
|
downloadArticleTorrentIfMatching(m_manager->downloadRules(), article);
|
||||||
if (matching_rule) {
|
|
||||||
// Torrent was downloaded, consider article as read
|
|
||||||
article->markAsRead();
|
|
||||||
// Download the torrent
|
|
||||||
QString torrent_url = article->torrentUrl();
|
|
||||||
QBtSession::instance()->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(article->title()).arg(displayName()));
|
|
||||||
if (torrent_url.startsWith("magnet:", Qt::CaseInsensitive))
|
|
||||||
QBtSession::instance()->addMagnetSkipAddDlg(torrent_url, matching_rule->savePath(), matching_rule->label());
|
|
||||||
else
|
|
||||||
QBtSession::instance()->downloadUrlAndSkipDialog(torrent_url, matching_rule->savePath(), matching_rule->label());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount);
|
m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount);
|
||||||
// FIXME: We should forward the information here but this would seriously decrease
|
// FIXME: We should forward the information here but this would seriously decrease
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
class RssFeed;
|
class RssFeed;
|
||||||
class RssManager;
|
class RssManager;
|
||||||
|
class RssDownloadRuleList;
|
||||||
|
|
||||||
typedef QHash<QString, RssArticlePtr> RssArticleHash;
|
typedef QHash<QString, RssArticlePtr> RssArticleHash;
|
||||||
typedef QSharedPointer<RssFeed> RssFeedPtr;
|
typedef QSharedPointer<RssFeed> RssFeedPtr;
|
||||||
@ -75,6 +76,7 @@ public:
|
|||||||
const RssArticleHash& articleHash() const { return m_articles; }
|
const RssArticleHash& articleHash() const { return m_articles; }
|
||||||
virtual RssArticleList unreadArticleListByDateDesc() const;
|
virtual RssArticleList unreadArticleListByDateDesc() const;
|
||||||
void decrementUnreadCount();
|
void decrementUnreadCount();
|
||||||
|
void recheckRssItemsForDownload();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleFinishedDownload(const QString& url, const QString &file_path);
|
void handleFinishedDownload(const QString& url, const QString &file_path);
|
||||||
@ -87,6 +89,7 @@ private:
|
|||||||
QString iconUrl() const;
|
QString iconUrl() const;
|
||||||
void loadItemsFromDisk();
|
void loadItemsFromDisk();
|
||||||
void addArticle(const RssArticlePtr& article);
|
void addArticle(const RssArticlePtr& article);
|
||||||
|
void downloadArticleTorrentIfMatching(RssDownloadRuleList* rules, const RssArticlePtr& article);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RssManager* m_manager;
|
RssManager* m_manager;
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
virtual RssArticleList unreadArticleListByDateDesc() const = 0;
|
virtual RssArticleList unreadArticleListByDateDesc() const = 0;
|
||||||
virtual void removeAllSettings() = 0;
|
virtual void removeAllSettings() = 0;
|
||||||
virtual void saveItemsToDisk() = 0;
|
virtual void saveItemsToDisk() = 0;
|
||||||
|
virtual void recheckRssItemsForDownload() = 0;
|
||||||
QStringList pathHierarchy() const;
|
QStringList pathHierarchy() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -251,3 +251,12 @@ RssFilePtr RssFolder::takeChild(const QString &childId)
|
|||||||
{
|
{
|
||||||
return m_children.take(childId);
|
return m_children.take(childId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RssFolder::recheckRssItemsForDownload()
|
||||||
|
{
|
||||||
|
RssFileHash::ConstIterator it = m_children.begin();
|
||||||
|
RssFileHash::ConstIterator itend = m_children.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
|
it.value()->recheckRssItemsForDownload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
void removeAllItems();
|
void removeAllItems();
|
||||||
void renameChildFolder(const QString &old_name, const QString &new_name);
|
void renameChildFolder(const QString &old_name, const QString &new_name);
|
||||||
RssFilePtr takeChild(const QString &childId);
|
RssFilePtr takeChild(const QString &childId);
|
||||||
|
void recheckRssItemsForDownload();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool refresh();
|
virtual bool refresh();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user