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:
@@ -98,6 +98,7 @@ SpotifyParser::lookupSpotifyBrowse( const QString& linkRaw )
|
||||
{
|
||||
tLog() << "Parsing Spotify Browse URI:" << linkRaw;
|
||||
m_browseUri = linkRaw;
|
||||
|
||||
if ( m_browseUri.contains( "open.spotify.com/" ) ) // convert to a URI
|
||||
{
|
||||
m_browseUri.replace( "http://open.spotify.com/", "" );
|
||||
@@ -105,6 +106,24 @@ SpotifyParser::lookupSpotifyBrowse( const QString& linkRaw )
|
||||
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;
|
||||
|
||||
if ( m_browseUri.contains( "spotify:user" ) )
|
||||
@@ -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
|
||||
SpotifyParser::checkBrowseFinished()
|
||||
{
|
||||
|
@@ -60,6 +60,9 @@ public:
|
||||
// the single track signal
|
||||
void setSingleMode( bool single ) { m_single = single; }
|
||||
|
||||
public slots:
|
||||
void playlistListingResult( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
||||
|
||||
signals:
|
||||
void track( const Tomahawk::query_ptr& track );
|
||||
void tracks( const QList< Tomahawk::query_ptr > tracks );
|
||||
|
Reference in New Issue
Block a user