3 #include <QDomDocument>
4 #include <QImageReader>
28 #define LOC QString("RSSEditor: ")
29 #define LOC_WARN QString("RSSEditor, Warning: ")
30 #define LOC_ERR QString("RSSEditor, Error: ")
40 QList<QByteArray> exts = QImageReader::supportedImageFormats();
41 for (
const auto & ext : std::as_const(exts))
42 ret.append(QString(
"*.").append(ext));
80 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditpopup'");
103 if (!thumb.isEmpty())
160 connect(
m_manager, &QNetworkAccessManager::finished,
this,
166 const QUrl& oldRedirectUrl)
169 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
176 QVariant possibleRedirectUrl =
177 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
179 QUrl urlRedirectedTo;
181 possibleRedirectUrl.toUrl(), urlRedirectedTo);
183 if (!urlRedirectedTo.isEmpty())
186 m_manager->get(QNetworkRequest(urlRedirectedTo));
193 reply->deleteLater();
198 QDomDocument document;
199 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
200 document.setContent(reply->read(reply->bytesAvailable()),
true);
202 document.setContent(reply->read(reply->bytesAvailable()),
203 QDomDocument::ParseOption::UseNamespaceProcessing);
206 QString text = document.toString();
213 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Text to Parse: %1").arg(text));
215 QDomElement root = document.documentElement();
216 QDomElement channel = root.firstChildElement (
"channel");
217 if (!channel.isNull())
221 title = channel.firstChildElement(
"title").text().trimmed();
222 if (description.isEmpty())
223 description = channel.firstChildElement(
"description").text();
224 if (author.isEmpty())
226 if (author.isEmpty())
227 author = channel.firstChildElement(
"managingEditor").text();
228 if (author.isEmpty())
229 author = channel.firstChildElement(
"webMaster").text();
231 QString thumbnailURL =
232 channel.firstChildElement(
"image").attribute(
"url");
233 if (thumbnailURL.isEmpty())
235 QDomElement thumbElem = channel.firstChildElement(
"image");
236 if (!thumbElem.isNull())
237 thumbnailURL = thumbElem.firstChildElement(
"url").text();
239 if (thumbnailURL.isEmpty())
241 QDomNodeList nodes = channel.elementsByTagNameNS(
242 "http://www.itunes.com/dtds/podcast-1.0.dtd",
247 nodes.at(0).toElement().attributeNode(
"href").value();
248 if (thumbnailURL.isEmpty())
249 thumbnailURL = nodes.at(0).toElement().text();
258 else if (!thumbnailURL.isEmpty())
280 QObject &inst,
const QString &returnEvent)
288 fb->SetReturnEvent(&inst, returnEvent);
313 QMutexLocker locker(&
m_lock);
321 QMutexLocker locker(&
m_lock);
343 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditor'");
400 for (
int i = 0; i < actions.size() && !handled; i++)
402 const QString&
action = actions[i];
428 QMutexLocker locker(&
m_lock);
432 for (
const auto & site : std::as_const(
m_siteList))
435 item->SetText(site->GetTitle(),
"title");
436 item->SetText(site->GetDescription(),
"description");
437 item->SetText(site->GetURL(),
"url");
438 item->SetText(site->GetAuthor(),
"author");
439 item->SetData(QVariant::fromValue(site));
440 item->SetImage(site->GetImage());
451 const QString& thumb = site->
GetImage();
455 if (!thumb.isEmpty())
474 QMutexLocker locker(&
m_lock);
477 tr(
"Are you sure you want to unsubscribe from this feed?");
484 if (confirmdialog->Create())
493 delete confirmdialog;
499 QMutexLocker locker(&
m_lock);
507 new RSSEditPopup(site->GetURL(),
true, mainStack,
"rsseditpopup");
509 if (rsseditpopup->Create())
524 QMutexLocker locker(&
m_lock);
528 auto *rsseditpopup =
new RSSEditPopup(
"",
false, mainStack,
"rsseditpopup");
530 if (rsseditpopup->Create())
544 QMutexLocker locker(&
m_lock);