diff --git a/src/libtomahawk/utils/NetworkReply.cpp b/src/libtomahawk/utils/NetworkReply.cpp index fb2f4d4b9..f366ae80e 100644 --- a/src/libtomahawk/utils/NetworkReply.cpp +++ b/src/libtomahawk/utils/NetworkReply.cpp @@ -46,6 +46,13 @@ NetworkReply::~NetworkReply() } +void +NetworkReply::blacklistHostFromRedirection( const QString& host ) +{ + m_blacklistedHosts << host; +} + + void NetworkReply::deletedByParent() { @@ -97,8 +104,16 @@ NetworkReply::networkLoadFinished() if ( redir.isValid() && !redir.toUrl().isEmpty() ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Redirected HTTP request to" << redir; - load( redir.toUrl() ); - emit redirected(); + if ( m_blacklistedHosts.contains( redir.toUrl().host() ) ) + { + tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Reached blacklisted host, not redirecting anymore."; + emit finished(); + } + else + { + load( redir.toUrl() ); + emit redirected(); + } } else emit finished(); diff --git a/src/libtomahawk/utils/NetworkReply.h b/src/libtomahawk/utils/NetworkReply.h index 5e0a6226b..d22009b25 100644 --- a/src/libtomahawk/utils/NetworkReply.h +++ b/src/libtomahawk/utils/NetworkReply.h @@ -21,6 +21,7 @@ #include #include +#include #include "Typedefs.h" @@ -34,6 +35,7 @@ public: explicit NetworkReply( QNetworkReply* parent = 0 ); virtual ~NetworkReply(); + void blacklistHostFromRedirection( const QString& host ); QNetworkReply* reply() const { return m_reply; } signals: @@ -49,6 +51,7 @@ private slots: private: void load( const QUrl& url ); + QStringList m_blacklistedHosts; QNetworkReply* m_reply; QUrl m_url; }; diff --git a/src/libtomahawk/utils/ShortenedLinkParser.cpp b/src/libtomahawk/utils/ShortenedLinkParser.cpp index 3ec524bc5..bf58cce5d 100644 --- a/src/libtomahawk/utils/ShortenedLinkParser.cpp +++ b/src/libtomahawk/utils/ShortenedLinkParser.cpp @@ -80,6 +80,12 @@ ShortenedLinkParser::lookupUrl( const QString& url ) cleaned.replace( "/#", "" ); NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( cleaned ) ) ) ); + + // Deezer is doing a nasty redirect to /comingsoon in some countries. + // This removes valubale information from the URL. + reply->blacklistHostFromRedirection( "www.deezer.com" ); + reply->blacklistHostFromRedirection( "deezer.com" ); + connect( reply, SIGNAL( finished() ), SLOT( lookupFinished() ) ); m_queries.insert( reply );