mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Better spotifyUri parsing, now allowing embed links to
This commit is contained in:
committed by
Hugo Lindström
parent
5f100891f6
commit
986730a51d
@@ -551,6 +551,8 @@ DropJob::handleXspfs( const QString& fileUrls )
|
|||||||
void
|
void
|
||||||
DropJob::handleSpotifyUrls( const QString& urlsRaw )
|
DropJob::handleSpotifyUrls( const QString& urlsRaw )
|
||||||
{
|
{
|
||||||
|
// Todo: Allow search querys, and split these in a better way.
|
||||||
|
// Example: spotify:search:artist:Madonna year:<1970 year:>1990
|
||||||
QStringList urls = urlsRaw.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
QStringList urls = urlsRaw.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
||||||
qDebug() << "Got spotify browse uris!" << urls;
|
qDebug() << "Got spotify browse uris!" << urls;
|
||||||
|
|
||||||
|
@@ -75,8 +75,29 @@ SpotifyParser::~SpotifyParser()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyParser::lookupUrl( const QString& link )
|
SpotifyParser::lookupUrl( const QString& rawLink )
|
||||||
{
|
{
|
||||||
|
tLog() << "Looking up Spotify rawURI:" << rawLink;
|
||||||
|
QString link = rawLink;
|
||||||
|
if ( link.contains( "open.spotify.com/" ) ) // convert to a URI
|
||||||
|
{
|
||||||
|
link.replace( "http://open.spotify.com/", "" );
|
||||||
|
link.replace( "/", ":" );
|
||||||
|
link = "spotify:" + link;
|
||||||
|
}
|
||||||
|
// TODO: Ignoring search and user querys atm
|
||||||
|
// (spotify:(?:(?:artist|album|track|user:[^:]+:playlist):[a-zA-Z0-9]+|user:[^:]+|search:(?:[-\w$\.+!*'(),<>:\s]+|%[a-fA-F0-9\s]{2})+))
|
||||||
|
QRegExp rx( "(spotify:(?:(?:artist|album|track|user:[^:]+:playlist):[a-zA-Z0-9]+[^:]))" );
|
||||||
|
if ( rx.indexIn( link, 0 ) != -1 )
|
||||||
|
{
|
||||||
|
link = rx.cap(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tLog() << "Bad SpotifyURI!" << link;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( link.contains( "track" ) )
|
if ( link.contains( "track" ) )
|
||||||
{
|
{
|
||||||
m_trackMode = true;
|
m_trackMode = true;
|
||||||
@@ -97,17 +118,12 @@ SpotifyParser::lookupUrl( const QString& link )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyParser::lookupSpotifyBrowse( const QString& linkRaw )
|
SpotifyParser::lookupSpotifyBrowse( const QString& link )
|
||||||
{
|
{
|
||||||
tLog() << "Parsing Spotify Browse URI:" << linkRaw;
|
tLog() << "Parsing Spotify Browse URI:" << link;
|
||||||
m_browseUri = linkRaw;
|
|
||||||
|
|
||||||
if ( m_browseUri.contains( "open.spotify.com/" ) ) // convert to a URI
|
// Used in checkBrowseFinished as identifier
|
||||||
{
|
m_browseUri = link;
|
||||||
m_browseUri.replace( "http://open.spotify.com/", "" );
|
|
||||||
m_browseUri.replace( "/", ":" );
|
|
||||||
m_browseUri = "spotify:" + m_browseUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_browseUri.contains( "playlist" ) &&
|
if ( m_browseUri.contains( "playlist" ) &&
|
||||||
Tomahawk::Accounts::SpotifyAccount::instance() != 0 &&
|
Tomahawk::Accounts::SpotifyAccount::instance() != 0 &&
|
||||||
|
@@ -79,7 +79,7 @@ private:
|
|||||||
|
|
||||||
void lookupUrl( const QString& url );
|
void lookupUrl( const QString& url );
|
||||||
void lookupTrack( const QString& track );
|
void lookupTrack( const QString& track );
|
||||||
void lookupSpotifyBrowse( const QString& playlist );
|
void lookupSpotifyBrowse(const QString& link );
|
||||||
void checkTrackFinished();
|
void checkTrackFinished();
|
||||||
void checkBrowseFinished();
|
void checkBrowseFinished();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user