mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Blacklist deezer redirects
This commit is contained in:
@@ -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();
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QStringList>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
@@ -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 );
|
||||
|
Reference in New Issue
Block a user