17 #define LOC QString("RSSSite: ")
22 : m_timer(new QTimer()),
23 m_updateFreq(
gCoreContext->GetDurSetting<std::chrono::hours>(
"rss.updateFreq", 6h))
48 for (
const auto *site : std::as_const(
m_sites))
50 LOG(VB_GENERAL, LOG_INFO,
LOC +
51 QString(
"Updating RSS Feed %1") .arg(site->GetTitle()));
86 for (
auto *video : std::as_const(rss))
113 m_title(std::move(title)), m_sortTitle(std::move(sortTitle)),
114 m_image(std::move(image)), m_type(
type),
115 m_description(std::move(description)), m_url(std::move(url)),
116 m_author(std::move(author)),
117 m_download(download), m_updated(std::move(updated))
126 QMutexLocker locker(&
m_lock);
132 QMutexLocker locker(&
m_lock);
138 QMutexLocker locker(&
m_lock);
145 connect(
m_manager, &QNetworkAccessManager::finished,
this,
153 const QUrl& oldRedirectUrl)
156 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
163 QVariant possibleRedirectUrl =
164 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
166 QUrl urlRedirectedTo;
167 urlRedirectedTo =
redirectUrl(possibleRedirectUrl.toUrl(),
170 if(!urlRedirectedTo.isEmpty())
172 m_manager->get(QNetworkRequest(urlRedirectedTo));
180 reply->deleteLater();
185 QMutexLocker locker(&
m_lock);
191 QMutexLocker locker(&
m_lock);
194 auto secs = std::chrono::seconds(
m_updated.secsTo(curTime));
195 return duration_cast<std::chrono::minutes>(secs);
200 QMutexLocker locker(&
m_lock);
212 if (!domDoc.setContent(
m_data,
true))
214 LOG(VB_GENERAL, LOG_ERR,
LOC +
215 "Failed to set content from downloaded XML");
221 QString rootName = domDoc.documentElement().nodeName();
222 if (rootName ==
"rss" || rootName ==
"rdf:RDF")
228 for (
const auto *item : std::as_const(items))
231 item->GetTitle(), item->GetSortTitle(),
232 item->GetSubtitle(), item->GetSortSubtitle(),
233 item->GetDescription(), item->GetURL(),
234 item->GetThumbnail(), item->GetMediaURL(),
235 item->GetAuthor(), item->GetDate(),
236 item->GetTime(), item->GetRating(),
237 item->GetFilesize(), item->GetPlayer(),
238 item->GetPlayerArguments(),
239 item->GetDownloader(),
240 item->GetDownloaderArguments(),
244 item->GetDownloadable(),
245 item->GetCountries(),
247 item->GetEpisode(),
false));
252 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Data is not valid RSS-feed");