replace original URL with redirected/final URL when guessing feed
This commit is contained in:
parent
793cbcbf58
commit
78dc97f23f
@ -146,7 +146,7 @@ void StandardFeedDetails::guessIconOnly(StandardFeed::SourceType source_type,
|
|||||||
const QList<QPair<QByteArray, QByteArray>>& headers,
|
const QList<QPair<QByteArray, QByteArray>>& headers,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
try {
|
try {
|
||||||
StandardFeed* metadata = StandardFeed::guessFeed(source_type,
|
auto metadata = StandardFeed::guessFeed(source_type,
|
||||||
source,
|
source,
|
||||||
post_process_script,
|
post_process_script,
|
||||||
protection,
|
protection,
|
||||||
@ -157,13 +157,13 @@ void StandardFeedDetails::guessIconOnly(StandardFeed::SourceType source_type,
|
|||||||
custom_proxy);
|
custom_proxy);
|
||||||
|
|
||||||
// Icon or whole feed was guessed.
|
// Icon or whole feed was guessed.
|
||||||
m_ui.m_btnIcon->setIcon(metadata->icon());
|
m_ui.m_btnIcon->setIcon(metadata.first->icon());
|
||||||
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Ok,
|
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
tr("Icon fetched successfully."),
|
tr("Icon fetched successfully."),
|
||||||
tr("Icon metadata fetched."));
|
tr("Icon metadata fetched."));
|
||||||
|
|
||||||
// Remove temporary feed object.
|
// Remove temporary feed object.
|
||||||
metadata->deleteLater();
|
metadata.first->deleteLater();
|
||||||
}
|
}
|
||||||
catch (const ScriptException& ex) {
|
catch (const ScriptException& ex) {
|
||||||
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
|
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
@ -191,7 +191,7 @@ void StandardFeedDetails::guessFeed(StandardFeed::SourceType source_type,
|
|||||||
const QList<QPair<QByteArray, QByteArray>>& headers,
|
const QList<QPair<QByteArray, QByteArray>>& headers,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
try {
|
try {
|
||||||
StandardFeed* metadata = StandardFeed::guessFeed(source_type,
|
auto metadata = StandardFeed::guessFeed(source_type,
|
||||||
source,
|
source,
|
||||||
post_process_script,
|
post_process_script,
|
||||||
protection,
|
protection,
|
||||||
@ -202,11 +202,16 @@ void StandardFeedDetails::guessFeed(StandardFeed::SourceType source_type,
|
|||||||
custom_proxy);
|
custom_proxy);
|
||||||
|
|
||||||
// Icon or whole feed was guessed.
|
// Icon or whole feed was guessed.
|
||||||
m_ui.m_btnIcon->setIcon(metadata->icon());
|
m_ui.m_btnIcon->setIcon(metadata.first->icon());
|
||||||
m_ui.m_txtTitle->lineEdit()->setText(metadata->sanitizedTitle());
|
m_ui.m_txtTitle->lineEdit()->setText(metadata.first->sanitizedTitle());
|
||||||
m_ui.m_txtDescription->lineEdit()->setText(metadata->description());
|
m_ui.m_txtDescription->lineEdit()->setText(metadata.first->description());
|
||||||
m_ui.m_cmbType->setCurrentIndex(m_ui.m_cmbType->findData(QVariant::fromValue((int)metadata->type())));
|
m_ui.m_cmbType->setCurrentIndex(m_ui.m_cmbType->findData(QVariant::fromValue((int)metadata.first->type())));
|
||||||
int encoding_index = m_ui.m_cmbEncoding->findText(metadata->encoding(), Qt::MatchFlag::MatchFixedString);
|
|
||||||
|
if (metadata.second.m_url.isValid()) {
|
||||||
|
m_ui.m_txtSource->textEdit()->setPlainText(metadata.second.m_url.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
int encoding_index = m_ui.m_cmbEncoding->findText(metadata.first->encoding(), Qt::MatchFlag::MatchFixedString);
|
||||||
|
|
||||||
if (encoding_index >= 0) {
|
if (encoding_index >= 0) {
|
||||||
m_ui.m_cmbEncoding->setCurrentIndex(encoding_index);
|
m_ui.m_cmbEncoding->setCurrentIndex(encoding_index);
|
||||||
@ -221,7 +226,7 @@ void StandardFeedDetails::guessFeed(StandardFeed::SourceType source_type,
|
|||||||
tr("Feed and icon metadata fetched."));
|
tr("Feed and icon metadata fetched."));
|
||||||
|
|
||||||
// Remove temporary feed object.
|
// Remove temporary feed object.
|
||||||
metadata->deleteLater();
|
metadata.first->deleteLater();
|
||||||
}
|
}
|
||||||
catch (const ScriptException& ex) {
|
catch (const ScriptException& ex) {
|
||||||
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
|
m_ui.m_lblFetchMetadata->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
@ -230,7 +230,7 @@ QString StandardFeed::sourceTypeToString(StandardFeed::SourceType type) {
|
|||||||
|
|
||||||
void StandardFeed::fetchMetadataForItself() {
|
void StandardFeed::fetchMetadataForItself() {
|
||||||
try {
|
try {
|
||||||
StandardFeed* metadata = guessFeed(sourceType(),
|
auto metadata = guessFeed(sourceType(),
|
||||||
source(),
|
source(),
|
||||||
postProcessScript(),
|
postProcessScript(),
|
||||||
protection(),
|
protection(),
|
||||||
@ -241,13 +241,17 @@ void StandardFeed::fetchMetadataForItself() {
|
|||||||
getParentServiceRoot()->networkProxy());
|
getParentServiceRoot()->networkProxy());
|
||||||
|
|
||||||
// Copy metadata to our object.
|
// Copy metadata to our object.
|
||||||
setTitle(metadata->title());
|
setTitle(metadata.first->title());
|
||||||
setDescription(metadata->description());
|
setDescription(metadata.first->description());
|
||||||
setType(metadata->type());
|
setType(metadata.first->type());
|
||||||
setEncoding(metadata->encoding());
|
setEncoding(metadata.first->encoding());
|
||||||
setIcon(metadata->icon());
|
setIcon(metadata.first->icon());
|
||||||
|
|
||||||
metadata->deleteLater();
|
if (metadata.second.m_url.isValid()) {
|
||||||
|
setSource(metadata.second.m_url.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
metadata.first->deleteLater();
|
||||||
|
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||||
|
|
||||||
@ -279,10 +283,11 @@ void StandardFeed::setSourceType(SourceType source_type) {
|
|||||||
m_sourceType = source_type;
|
m_sourceType = source_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
|
QPair<StandardFeed*, NetworkResult> StandardFeed::guessFeed(StandardFeed::SourceType source_type,
|
||||||
const QString& source,
|
const QString& source,
|
||||||
const QString& post_process_script,
|
const QString& post_process_script,
|
||||||
NetworkFactory::NetworkFactory::NetworkAuthentication protection,
|
NetworkFactory::NetworkFactory::NetworkAuthentication
|
||||||
|
protection,
|
||||||
bool fetch_icons,
|
bool fetch_icons,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& password,
|
const QString& password,
|
||||||
@ -406,7 +411,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return feed;
|
return {feed, network_result};
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags StandardFeed::additionalFlags() const {
|
Qt::ItemFlags StandardFeed::additionalFlags() const {
|
||||||
|
@ -79,7 +79,7 @@ class StandardFeed : public Feed {
|
|||||||
// Returns pointer to guessed feed (if at least partially
|
// Returns pointer to guessed feed (if at least partially
|
||||||
// guessed) and retrieved error/status code from network layer
|
// guessed) and retrieved error/status code from network layer
|
||||||
// or nullptr feed.
|
// or nullptr feed.
|
||||||
static StandardFeed* guessFeed(SourceType source_type,
|
static QPair<StandardFeed*, NetworkResult> guessFeed(SourceType source_type,
|
||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& post_process_script,
|
const QString& post_process_script,
|
||||||
NetworkFactory::NetworkAuthentication protection,
|
NetworkFactory::NetworkAuthentication protection,
|
||||||
@ -87,7 +87,8 @@ class StandardFeed : public Feed {
|
|||||||
const QString& username = {},
|
const QString& username = {},
|
||||||
const QString& password = {},
|
const QString& password = {},
|
||||||
const QList<QPair<QByteArray, QByteArray>>& http_headers = {},
|
const QList<QPair<QByteArray, QByteArray>>& http_headers = {},
|
||||||
const QNetworkProxy& custom_proxy = QNetworkProxy::ProxyType::DefaultProxy);
|
const QNetworkProxy& custom_proxy =
|
||||||
|
QNetworkProxy::ProxyType::DefaultProxy);
|
||||||
|
|
||||||
// Converts particular feed type to string.
|
// Converts particular feed type to string.
|
||||||
static QString typeToString(Type type);
|
static QString typeToString(Type type);
|
||||||
|
@ -196,7 +196,7 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
: feed_lookup.post_process_script;
|
: feed_lookup.post_process_script;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new_feed = StandardFeed::guessFeed(source_type,
|
auto new_feed_data = StandardFeed::guessFeed(source_type,
|
||||||
feed_lookup.url,
|
feed_lookup.url,
|
||||||
pp_script,
|
pp_script,
|
||||||
NetworkFactory::NetworkAuthentication::NoAuthentication,
|
NetworkFactory::NetworkAuthentication::NoAuthentication,
|
||||||
@ -206,9 +206,10 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
{},
|
{},
|
||||||
feed_lookup.custom_proxy);
|
feed_lookup.custom_proxy);
|
||||||
|
|
||||||
new_feed->setSourceType(source_type);
|
new_feed_data.first->setSourceType(source_type);
|
||||||
new_feed->setSource(feed_lookup.url);
|
new_feed_data.first->setPostProcessScript(pp_script);
|
||||||
new_feed->setPostProcessScript(pp_script);
|
|
||||||
|
new_feed = new_feed_data.first;
|
||||||
|
|
||||||
if (feed_lookup.do_not_fetch_titles) {
|
if (feed_lookup.do_not_fetch_titles) {
|
||||||
QString old_title = feed_lookup.custom_data[QSL("title")].toString();
|
QString old_title = feed_lookup.custom_data[QSL("title")].toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user