mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
TWK-459: More rdio unbreaking and add support in rdioURI/rdioURL tomahawk urls
This commit is contained in:
@@ -357,6 +357,8 @@ GlobalActionManager::doQueueAdd( const QStringList& parts, const QList< QPair< Q
|
|||||||
|
|
||||||
if( queueSpotify( parts, queryItems ) )
|
if( queueSpotify( parts, queryItems ) )
|
||||||
return true;
|
return true;
|
||||||
|
else if( queueRdio( parts, queryItems ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
QPair< QString, QString > pair;
|
QPair< QString, QString > pair;
|
||||||
|
|
||||||
@@ -427,6 +429,26 @@ GlobalActionManager::queueSpotify( const QStringList& , const QList< QPair< QStr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GlobalActionManager::queueRdio( const QStringList& , const QList< QPair< QString, QString > >& queryItems )
|
||||||
|
{
|
||||||
|
QString url;
|
||||||
|
|
||||||
|
QPair< QString, QString > pair;
|
||||||
|
foreach( pair, queryItems ) {
|
||||||
|
if( pair.first == "rdioURL" )
|
||||||
|
url = pair.second;
|
||||||
|
else if( pair.first == "rdioURI" )
|
||||||
|
url = pair.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( url.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
openRdioLink( url );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GlobalActionManager::handleSearchCommand( const QUrl& url )
|
GlobalActionManager::handleSearchCommand( const QUrl& url )
|
||||||
@@ -617,6 +639,8 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
|
|||||||
if( parts[ 0 ] == "track" ) {
|
if( parts[ 0 ] == "track" ) {
|
||||||
if( playSpotify( url ) )
|
if( playSpotify( url ) )
|
||||||
return true;
|
return true;
|
||||||
|
else if( playRdio( url ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
QPair< QString, QString > pair;
|
QPair< QString, QString > pair;
|
||||||
QString title, artist, album, urlStr;
|
QString title, artist, album, urlStr;
|
||||||
@@ -652,13 +676,13 @@ GlobalActionManager::playSpotify( const QUrl& url )
|
|||||||
|
|
||||||
QString spotifyUrl = url.hasQueryItem( "spotifyURI" ) ? url.queryItemValue( "spotifyURI" ) : url.queryItemValue( "spotifyURL" );
|
QString spotifyUrl = url.hasQueryItem( "spotifyURI" ) ? url.queryItemValue( "spotifyURI" ) : url.queryItemValue( "spotifyURL" );
|
||||||
SpotifyParser* p = new SpotifyParser( spotifyUrl, this );
|
SpotifyParser* p = new SpotifyParser( spotifyUrl, this );
|
||||||
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( spotifyToPlay( Tomahawk::query_ptr ) ) );
|
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playNow( Tomahawk::query_ptr ) ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::spotifyToPlay( const query_ptr& q )
|
GlobalActionManager::playNow( const query_ptr& q )
|
||||||
{
|
{
|
||||||
Pipeline::instance()->resolve( q, true );
|
Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
@@ -666,6 +690,21 @@ GlobalActionManager::spotifyToPlay( const query_ptr& q )
|
|||||||
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
|
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GlobalActionManager::playRdio( const QUrl& url )
|
||||||
|
{
|
||||||
|
if( !url.hasQueryItem( "rdioURI" ) && !url.hasQueryItem( "rdioURL" ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
QString rdioUrl = url.hasQueryItem( "rdioURI" ) ? url.queryItemValue( "spotifyURI" ) : url.queryItemValue( "rdioURL" );
|
||||||
|
RdioParser* p = new RdioParser( this );
|
||||||
|
p->parse( rdioUrl );
|
||||||
|
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playNow( Tomahawk::query_ptr ) ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
||||||
{
|
{
|
||||||
|
@@ -65,7 +65,7 @@ private slots:
|
|||||||
|
|
||||||
void xspfCreated( const QByteArray& xspf );
|
void xspfCreated( const QByteArray& xspf );
|
||||||
|
|
||||||
void spotifyToPlay( const Tomahawk::query_ptr& );
|
void playNow( const Tomahawk::query_ptr& );
|
||||||
private:
|
private:
|
||||||
explicit GlobalActionManager( QObject* parent = 0 );
|
explicit GlobalActionManager( QObject* parent = 0 );
|
||||||
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
void doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahawk::query_ptr& q );
|
||||||
@@ -84,6 +84,8 @@ private:
|
|||||||
|
|
||||||
bool playSpotify( const QUrl& url );
|
bool playSpotify( const QUrl& url );
|
||||||
bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
bool queueSpotify( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
||||||
|
bool playRdio( const QUrl& url );
|
||||||
|
bool queueRdio( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
|
||||||
|
|
||||||
QString hostname() const;
|
QString hostname() const;
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include "shortenedlinkparser.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -55,6 +56,13 @@ RdioParser::parse( const QStringList& urls )
|
|||||||
void
|
void
|
||||||
RdioParser::parseUrl( const QString& url )
|
RdioParser::parseUrl( const QString& url )
|
||||||
{
|
{
|
||||||
|
if ( url.contains( "rd.io" ) ) // shortened
|
||||||
|
{
|
||||||
|
ShortenedLinkParser* p = new ShortenedLinkParser( QStringList() << url, this );
|
||||||
|
connect( p, SIGNAL( urls( QStringList ) ), this, SLOT( expandedLinks( QStringList ) ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
query_ptr query;
|
query_ptr query;
|
||||||
m_count++;
|
m_count++;
|
||||||
|
|
||||||
@@ -99,3 +107,13 @@ RdioParser::parseUrl( const QString& url )
|
|||||||
emit track( query );
|
emit track( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RdioParser::expandedLinks( const QStringList& urls )
|
||||||
|
{
|
||||||
|
foreach( const QString& url, urls )
|
||||||
|
{
|
||||||
|
if ( url.contains( "rdio.com" ) || url.contains( "rd.io" ) )
|
||||||
|
parseUrl( url );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -49,6 +49,9 @@ 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 );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void expandedLinks( const QStringList& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseUrl( const QString& url );
|
void parseUrl( const QString& url );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user