1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 12:21:52 +02:00

Ask local resolver for playlist if running and logged in

This commit is contained in:
Leo Franchi
2012-07-17 10:10:00 -04:00
parent a6134533be
commit ba16ca9a72
2 changed files with 47 additions and 0 deletions

View File

@@ -98,12 +98,31 @@ SpotifyParser::lookupSpotifyBrowse( const QString& linkRaw )
{ {
tLog() << "Parsing Spotify Browse URI:" << linkRaw; tLog() << "Parsing Spotify Browse URI:" << linkRaw;
m_browseUri = linkRaw; m_browseUri = linkRaw;
if ( m_browseUri.contains( "open.spotify.com/" ) ) // convert to a URI if ( m_browseUri.contains( "open.spotify.com/" ) ) // convert to a URI
{ {
m_browseUri.replace( "http://open.spotify.com/", "" ); m_browseUri.replace( "http://open.spotify.com/", "" );
m_browseUri.replace( "/", ":" ); m_browseUri.replace( "/", ":" );
m_browseUri = "spotify:" + m_browseUri; m_browseUri = "spotify:" + m_browseUri;
} }
if ( m_browseUri.contains( "playlist" ) &&
Tomahawk::Accounts::SpotifyAccount::instance() != 0 &&
Tomahawk::Accounts::SpotifyAccount::instance()->loggedIn() )
{
// Do a playlist lookup locally
// Running resolver, so do the lookup through that
qDebug() << Q_FUNC_INFO << "Doing playlist lookup through spotify resolver:" << m_browseUri;
QVariantMap message;
message[ "_msgtype" ] = "playlistListing";
message[ "id" ] = m_browseUri;
QMetaObject::invokeMethod( Tomahawk::Accounts::SpotifyAccount::instance(), "sendMessage", Qt::QueuedConnection, Q_ARG( QVariantMap, message ),
Q_ARG( QObject*, this ),
Q_ARG( QString, "playlistListingResult" ) );
return;
}
DropJob::DropType type; DropJob::DropType type;
@@ -293,6 +312,31 @@ SpotifyParser::spotifyTrackLookupFinished()
} }
void
SpotifyParser::playlistListingResult( const QString& msgType, const QVariantMap& msg, const QVariant& extraData )
{
Q_ASSERT( msgType == "playlistListing" );
m_title = msg.value( "name" ).toString();
m_single = false;
m_creator = msg.value( "creator" ).toString();
const QVariantList tracks = msg.value( "tracks" ).toList();
foreach ( const QVariant& blob, tracks )
{
QVariantMap trackMap = blob.toMap();
const query_ptr q = Query::get( trackMap.value( "artist" ).toString(), trackMap.value( "track" ).toString(), trackMap.value( "album" ).toString(), uuid(), false );
if ( q.isNull() )
continue;
m_tracks << q;
}
checkBrowseFinished();
}
void void
SpotifyParser::checkBrowseFinished() SpotifyParser::checkBrowseFinished()
{ {

View File

@@ -60,6 +60,9 @@ public:
// the single track signal // the single track signal
void setSingleMode( bool single ) { m_single = single; } void setSingleMode( bool single ) { m_single = single; }
public slots:
void playlistListingResult( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
signals: signals:
void track( const Tomahawk::query_ptr& track ); void track( const Tomahawk::query_ptr& track );
void tracks( const QList< Tomahawk::query_ptr > tracks ); void tracks( const QList< Tomahawk::query_ptr > tracks );