mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-08 13:10:50 +02:00
* Use largest album cover size last.fm offers.
This commit is contained in:
committed by
Michael Zanetti
parent
f1f577053b
commit
aaa0affad4
@@ -520,19 +520,12 @@ LastFmInfoPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::In
|
|||||||
QString artistName = criteria["artist"];
|
QString artistName = criteria["artist"];
|
||||||
QString albumName = criteria["album"];
|
QString albumName = criteria["album"];
|
||||||
|
|
||||||
QUrl imgurl( "http://ws.audioscrobbler.com/2.0/" );
|
lastfm::Artist lfmArtist( artistName );
|
||||||
imgurl.addQueryItem( "method", "album.imageredirect" );
|
lastfm::Album lfmAlbum( lfmArtist, albumName );
|
||||||
imgurl.addEncodedQueryItem( "artist", QUrl::toPercentEncoding( artistName, "", "+" ) );
|
|
||||||
imgurl.addEncodedQueryItem( "album", QUrl::toPercentEncoding( albumName, "", "+" ) );
|
|
||||||
imgurl.addQueryItem( "autocorrect", QString::number( 1 ) );
|
|
||||||
imgurl.addQueryItem( "size", "large" );
|
|
||||||
imgurl.addQueryItem( "api_key", "7a90f6672a04b809ee309af169f34b8b" );
|
|
||||||
|
|
||||||
QNetworkRequest req( imgurl );
|
QNetworkReply* reply = lfmAlbum.getInfo();
|
||||||
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
|
|
||||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||||
|
connect( reply, SIGNAL( finished() ), SLOT( albumInfoReturned() ) );
|
||||||
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,6 +719,40 @@ LastFmInfoPlugin::topTracksReturned()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LastFmInfoPlugin::albumInfoReturned()
|
||||||
|
{
|
||||||
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
|
QHash< QString, QString > covers;
|
||||||
|
QString url;
|
||||||
|
|
||||||
|
lastfm::XmlQuery lfm;
|
||||||
|
lfm.parse( reply->readAll() );
|
||||||
|
|
||||||
|
foreach ( lastfm::XmlQuery xq, lfm.children( "album" ) )
|
||||||
|
{
|
||||||
|
foreach ( lastfm::XmlQuery xxq, xq.children( "image" ) )
|
||||||
|
{
|
||||||
|
covers[ xxq.attribute( "size" ).toLower() ] = xxq.text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( covers.contains( "mega" ) )
|
||||||
|
url = covers[ "mega" ];
|
||||||
|
else if ( covers.contains( "extralarge" ) )
|
||||||
|
url = covers[ "extralarge" ];
|
||||||
|
else if ( covers.contains( "large" ) )
|
||||||
|
url = covers[ "large" ];
|
||||||
|
else if ( covers.contains( "medium" ) )
|
||||||
|
url = covers[ "medium" ];
|
||||||
|
|
||||||
|
QNetworkRequest req( url );
|
||||||
|
QNetworkReply* newReply = TomahawkUtils::nam()->get( req );
|
||||||
|
newReply->setProperty( "requestData", reply->property( "requestData" ) );
|
||||||
|
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmInfoPlugin::coverArtReturned()
|
LastFmInfoPlugin::coverArtReturned()
|
||||||
{
|
{
|
||||||
|
@@ -61,6 +61,7 @@ public slots:
|
|||||||
void topTracksReturned();
|
void topTracksReturned();
|
||||||
void chartReturned();
|
void chartReturned();
|
||||||
void similarTracksReturned();
|
void similarTracksReturned();
|
||||||
|
void albumInfoReturned();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
Reference in New Issue
Block a user