mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Implement ChartInfoCapabilities in the lastfm plugin
This commit is contained in:
@@ -33,6 +33,8 @@
|
|||||||
#include <lastfm/ws.h>
|
#include <lastfm/ws.h>
|
||||||
#include <lastfm/XmlQuery>
|
#include <lastfm/XmlQuery>
|
||||||
|
|
||||||
|
#include <qjson/parser.h>
|
||||||
|
|
||||||
using namespace Tomahawk::InfoSystem;
|
using namespace Tomahawk::InfoSystem;
|
||||||
|
|
||||||
static QString
|
static QString
|
||||||
@@ -47,7 +49,7 @@ LastFmPlugin::LastFmPlugin()
|
|||||||
: InfoPlugin()
|
: InfoPlugin()
|
||||||
, m_scrobbler( 0 )
|
, m_scrobbler( 0 )
|
||||||
{
|
{
|
||||||
m_supportedGetTypes << InfoAlbumCoverArt << InfoArtistImages << InfoArtistSimilars << InfoArtistSongs << InfoChartArtists << InfoChartTracks;
|
m_supportedGetTypes << InfoAlbumCoverArt << InfoArtistImages << InfoArtistSimilars << InfoArtistSongs << InfoChartArtists << InfoChartTracks << InfoChartCapabilities;
|
||||||
m_supportedPushTypes << InfoSubmitScrobble << InfoSubmitNowPlaying << InfoLove << InfoUnLove;
|
m_supportedPushTypes << InfoSubmitScrobble << InfoSubmitNowPlaying << InfoLove << InfoUnLove;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -155,7 +157,9 @@ LastFmPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData req
|
|||||||
case InfoChartTracks:
|
case InfoChartTracks:
|
||||||
fetchChartTracks( requestId, requestData );
|
fetchChartTracks( requestId, requestData );
|
||||||
break;
|
break;
|
||||||
|
case InfoChartCapabilities:
|
||||||
|
fetchChartCapabilities( requestId, requestData );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dataError( requestId, requestData );
|
dataError( requestId, requestData );
|
||||||
}
|
}
|
||||||
@@ -345,6 +349,20 @@ LastFmPlugin::fetchChartTracks( uint requestId, Tomahawk::InfoSystem::InfoReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LastFmPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||||
|
{
|
||||||
|
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
||||||
|
{
|
||||||
|
dataError( requestId, requestData );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
||||||
|
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
|
||||||
|
|
||||||
|
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
LastFmPlugin::fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||||
{
|
{
|
||||||
@@ -440,6 +458,27 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case InfoChartCapabilities:
|
||||||
|
{
|
||||||
|
tDebug() << "LastfmPlugin: InfoChartCapabilities not in cache, fetching";
|
||||||
|
QString json("{'Last.fm': {'Tracks': ['Top Tracks','Hyped Tracks','Most Loved Tracks'],"
|
||||||
|
"'Artists': ['Top Artists', 'Hyped Artists']}}");
|
||||||
|
json.replace("'", "\"");
|
||||||
|
QJson::Parser parser;
|
||||||
|
bool ok = false;
|
||||||
|
QVariantMap result = parser.parse (json.toUtf8(), &ok).toMap();
|
||||||
|
if(!ok) {
|
||||||
|
tDebug() << "Lastfm Plugin: parsing json failed";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit info(
|
||||||
|
requestId,
|
||||||
|
requestData,
|
||||||
|
result
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case InfoArtistSimilars:
|
case InfoArtistSimilars:
|
||||||
{
|
{
|
||||||
lastfm::Artist a( criteria["artist"] );
|
lastfm::Artist a( criteria["artist"] );
|
||||||
|
@@ -70,6 +70,7 @@ private:
|
|||||||
void fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
void fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
void fetchChartArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
void fetchChartArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
void fetchChartTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
void fetchChartTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
|
void fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
|
|
||||||
void createScrobbler();
|
void createScrobbler();
|
||||||
void nowPlaying( const QVariant &input );
|
void nowPlaying( const QVariant &input );
|
||||||
|
Reference in New Issue
Block a user