diff --git a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp index f6296268f..2ce6f532e 100644 --- a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp +++ b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp @@ -48,15 +48,21 @@ using namespace Tomahawk::InfoSystem; bool newReleaseSort( const InfoStringHash& left, const InfoStringHash& right ) { - if ( !left.contains( "date" ) || !right.contains( "date" ) ) + if ( left.contains( "rank" ) && right.contains( "rank" ) ) { - return true; + const int lRank = left[ "rank" ].toInt(); + const int rRank = right[ "rank" ].toInt(); + return lRank < rRank; } - const QDate lDate = QDate::fromString( left[ "date" ], "yyyy-MM-dd" ); - const QDate rDate = QDate::fromString( right[ "date" ], "yyyy-MM-dd" ); + if ( left.contains( "date" ) && right.contains( "date" ) ) + { + const QDate lDate = QDate::fromString( left[ "date" ], "yyyy-MM-dd" ); + const QDate rDate = QDate::fromString( right[ "date" ], "yyyy-MM-dd" ); + return lDate > rDate; + } - return lDate > rDate; + return true; } @@ -64,7 +70,7 @@ NewReleasesPlugin::NewReleasesPlugin() : InfoPlugin() , m_nrFetchJobs( 0 ) { - m_nrVersion = "0.5.1"; + m_nrVersion = "0.5.2"; m_supportedGetTypes << InfoNewReleaseCapabilities << InfoNewRelease; } @@ -685,11 +691,12 @@ NewReleasesPlugin::nrReturned() const QString album = albumMap.value( "album" ).toString(); const QString artist = albumMap.value( "artist" ).toString(); const QString date = albumMap.value( "date" ).toString(); - + const QString rank = albumMap.value( "rank" ).toString(); Tomahawk::InfoSystem::InfoStringHash pair; pair[ "artist" ] = artist; pair[ "album" ] = album; pair[ "date" ] = date; + pair[ "rank" ] = rank; newreleases.append( pair ); } }