mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
Add support for RSS feeds using magnet links (Closes #1016379)
This commit is contained in:
@@ -326,23 +326,32 @@ void RSSImp::downloadTorrent() {
|
||||
foreach (const QListWidgetItem* item, selected_items) {
|
||||
RssArticlePtr article = m_feedList->getRSSItemFromUrl(item->data(Article::FeedUrlRole).toString())
|
||||
->getItem(item->data(Article::IdRole).toString());
|
||||
// Load possible cookies
|
||||
QList<QNetworkCookie> cookies;
|
||||
QString feed_url = m_feedList->getItemID(m_feedList->selectedItems().first());
|
||||
QString feed_hostname = QUrl::fromEncoded(feed_url.toUtf8()).host();
|
||||
const QList<QByteArray> raw_cookies = RssSettings().getHostNameCookies(feed_hostname);
|
||||
foreach (const QByteArray& raw_cookie, raw_cookies) {
|
||||
QList<QByteArray> cookie_parts = raw_cookie.split('=');
|
||||
if (cookie_parts.size() == 2) {
|
||||
qDebug("Loading cookie: %s = %s", cookie_parts.first().constData(), cookie_parts.last().constData());
|
||||
cookies << QNetworkCookie(cookie_parts.first(), cookie_parts.last());
|
||||
|
||||
QString torrentLink;
|
||||
if (article->hasAttachment())
|
||||
torrentLink = article->torrentUrl();
|
||||
else
|
||||
torrentLink = article->link();
|
||||
|
||||
// Check if it is a magnet link
|
||||
if (torrentLink.startsWith("magnet:", Qt::CaseInsensitive))
|
||||
QBtSession::instance()->addMagnetInteractive(torrentLink);
|
||||
else {
|
||||
// Load possible cookies
|
||||
QList<QNetworkCookie> cookies;
|
||||
QString feed_url = m_feedList->getItemID(m_feedList->selectedItems().first());
|
||||
QString feed_hostname = QUrl::fromEncoded(feed_url.toUtf8()).host();
|
||||
const QList<QByteArray> raw_cookies = RssSettings().getHostNameCookies(feed_hostname);
|
||||
foreach (const QByteArray& raw_cookie, raw_cookies) {
|
||||
QList<QByteArray> cookie_parts = raw_cookie.split('=');
|
||||
if (cookie_parts.size() == 2) {
|
||||
qDebug("Loading cookie: %s = %s", cookie_parts.first().constData(), cookie_parts.last().constData());
|
||||
cookies << QNetworkCookie(cookie_parts.first(), cookie_parts.last());
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug("Loaded %d cookies for RSS item\n", cookies.size());
|
||||
if (article->hasAttachment()) {
|
||||
QBtSession::instance()->downloadFromUrl(article->torrentUrl(), cookies);
|
||||
} else {
|
||||
QBtSession::instance()->downloadFromUrl(article->link(), cookies);
|
||||
qDebug("Loaded %d cookies for RSS item\n", cookies.size());
|
||||
|
||||
QBtSession::instance()->downloadFromUrl(torrentLink, cookies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,10 @@ void RssFeed::downloadMatchingArticleTorrents() {
|
||||
// Download the torrent
|
||||
QString torrent_url = article->hasAttachment() ? article->torrentUrl() : article->link();
|
||||
QBtSession::instance()->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(article->title()).arg(displayName()));
|
||||
QBtSession::instance()->downloadUrlAndSkipDialog(torrent_url, matching_rule->savePath(), matching_rule->label());
|
||||
if (torrent_url.startsWith("magnet:", Qt::CaseInsensitive))
|
||||
QBtSession::instance()->addMagnetSkipAddDlg(torrent_url);
|
||||
else
|
||||
QBtSession::instance()->downloadUrlAndSkipDialog(torrent_url, matching_rule->savePath(), matching_rule->label());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user