mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Accept http[s] and play/open links from spotify.
This commit is contained in:
@@ -79,17 +79,25 @@ SpotifyParser::lookupUrl( const QString& rawLink )
|
|||||||
{
|
{
|
||||||
tLog() << "Looking up Spotify rawURI:" << rawLink;
|
tLog() << "Looking up Spotify rawURI:" << rawLink;
|
||||||
QString link = rawLink;
|
QString link = rawLink;
|
||||||
if ( link.contains( "open.spotify.com/" ) ) // convert to a URI
|
|
||||||
{
|
QRegExp isHttp("(?:((play|open)\\.spotify.com))(.*)");
|
||||||
link.replace( "http://", "" ).replace( "open.spotify.com/", "" );
|
|
||||||
link.replace( "/", ":" );
|
|
||||||
link = "spotify:" + link;
|
|
||||||
}
|
|
||||||
// Some spotify apps contain the link to the playlist as url-encoded in their link (e.g. ShareMyPlaylists)
|
// Some spotify apps contain the link to the playlist as url-encoded in their link (e.g. ShareMyPlaylists)
|
||||||
if ( link.contains( "%3A" ) )
|
if ( link.contains( "%253A" ) )
|
||||||
{
|
{
|
||||||
link = QUrl::fromPercentEncoding( link.toUtf8() );
|
link = QUrl::fromPercentEncoding( link.toUtf8() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( link.contains( "%3A" ) )
|
||||||
|
{
|
||||||
|
link = QUrl::fromPercentEncoding( link.toUtf8() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( isHttp.indexIn( link, 0 ) != -1 )
|
||||||
|
{
|
||||||
|
link = "spotify"+isHttp.cap(3).replace("/", ":");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Ignoring search and user querys atm
|
// 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})+))
|
// (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]+[^:]))" );
|
QRegExp rx( "(spotify:(?:(?:artist|album|track|user:[^:]+:playlist):[a-zA-Z0-9]+[^:]))" );
|
||||||
|
Reference in New Issue
Block a user