mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Initial mp3 url support
This commit is contained in:
@@ -645,8 +645,12 @@ GlobalActionManager::doQueueAdd( const QStringList& parts, const QList< QPair< Q
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !urlStr.isEmpty() )
|
if ( !urlStr.isEmpty() )
|
||||||
|
{
|
||||||
q->setResultHint( urlStr );
|
q->setResultHint( urlStr );
|
||||||
Pipeline::instance()->resolve( q );
|
q->setSaveHTTPResultHint( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
handleOpenTrack( q );
|
handleOpenTrack( q );
|
||||||
return true;
|
return true;
|
||||||
@@ -668,9 +672,14 @@ GlobalActionManager::doQueueAdd( const QStringList& parts, const QList< QPair< Q
|
|||||||
{ // give it a web result hint
|
{ // give it a web result hint
|
||||||
QFileInfo info( track.path() );
|
QFileInfo info( track.path() );
|
||||||
query_ptr q = Query::get( QString(), info.baseName(), QString(), uuid(), false );
|
query_ptr q = Query::get( QString(), info.baseName(), QString(), uuid(), false );
|
||||||
|
|
||||||
if ( q.isNull() )
|
if ( q.isNull() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
q->setResultHint( track.toString() );
|
||||||
|
q->setSaveHTTPResultHint( true );
|
||||||
|
|
||||||
|
|
||||||
q->setResultHint( track.toString() );
|
q->setResultHint( track.toString() );
|
||||||
Pipeline::instance()->resolve( q );
|
Pipeline::instance()->resolve( q );
|
||||||
|
|
||||||
@@ -1075,7 +1084,10 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !urlStr.isEmpty() )
|
if ( !urlStr.isEmpty() )
|
||||||
|
{
|
||||||
q->setResultHint( urlStr );
|
q->setResultHint( urlStr );
|
||||||
|
q->setSaveHTTPResultHint( true );
|
||||||
|
}
|
||||||
|
|
||||||
playNow( q );
|
playNow( q );
|
||||||
return true;
|
return true;
|
||||||
@@ -1166,8 +1178,11 @@ bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !urlStr.isEmpty() )
|
if ( !urlStr.isEmpty() )
|
||||||
|
{
|
||||||
q->setResultHint( urlStr );
|
q->setResultHint( urlStr );
|
||||||
Pipeline::instance()->resolve( q );
|
q->setSaveHTTPResultHint( true );
|
||||||
|
}
|
||||||
|
Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
// now we add it to the special "bookmarks" playlist, creating it if it doesn't exist. if nothing is playing, start playing the track
|
// now we add it to the special "bookmarks" playlist, creating it if it doesn't exist. if nothing is playing, start playing the track
|
||||||
QSharedPointer< LocalCollection > col = SourceList::instance()->getLocal()->collection().dynamicCast< LocalCollection >();
|
QSharedPointer< LocalCollection > col = SourceList::instance()->getLocal()->collection().dynamicCast< LocalCollection >();
|
||||||
|
@@ -164,6 +164,7 @@ Query::init()
|
|||||||
m_duration = -1;
|
m_duration = -1;
|
||||||
m_albumpos = 0;
|
m_albumpos = 0;
|
||||||
m_discnumber = 0;
|
m_discnumber = 0;
|
||||||
|
m_saveResultHint = false;
|
||||||
|
|
||||||
updateSortNames();
|
updateSortNames();
|
||||||
}
|
}
|
||||||
|
@@ -164,6 +164,9 @@ public:
|
|||||||
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
|
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
|
||||||
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
|
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
|
||||||
|
|
||||||
|
void setSaveHTTPResultHint( bool saveResultHint ) { m_saveResultHint = saveResultHint; }
|
||||||
|
bool saveHTTPResultHint() const { return m_saveResultHint; }
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> similarTracks() const;
|
QList<Tomahawk::query_ptr> similarTracks() const;
|
||||||
QStringList lyrics() const;
|
QStringList lyrics() const;
|
||||||
|
|
||||||
@@ -254,6 +257,8 @@ private:
|
|||||||
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
|
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
|
||||||
QList< QWeakPointer< Tomahawk::Resolver > > m_resolvers;
|
QList< QWeakPointer< Tomahawk::Resolver > > m_resolvers;
|
||||||
|
|
||||||
|
bool m_saveResultHint;
|
||||||
|
|
||||||
mutable QMutex m_mutex;
|
mutable QMutex m_mutex;
|
||||||
QWeakPointer< Tomahawk::Query > m_ownRef;
|
QWeakPointer< Tomahawk::Query > m_ownRef;
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
|
|||||||
qDebug() << "Using result-hint to speed up resolving:" << m_query->resultHint();
|
qDebug() << "Using result-hint to speed up resolving:" << m_query->resultHint();
|
||||||
|
|
||||||
Tomahawk::result_ptr result = lib->resultFromHint( m_query );
|
Tomahawk::result_ptr result = lib->resultFromHint( m_query );
|
||||||
if ( !result.isNull() && !result->collection().isNull() && result->collection()->source()->isOnline() )
|
if ( !result.isNull() && ( result->collection().isNull() || result->collection()->source()->isOnline() ) )
|
||||||
{
|
{
|
||||||
QList<Tomahawk::result_ptr> res;
|
QList<Tomahawk::result_ptr> res;
|
||||||
res << result;
|
res << result;
|
||||||
|
@@ -199,11 +199,23 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
|
|
||||||
m_addedmap.insert( e->guid(), e ); // needed in postcommithook
|
m_addedmap.insert( e->guid(), e ); // needed in postcommithook
|
||||||
|
|
||||||
QString resultHint;
|
QString resultHint, foundResult;
|
||||||
|
// Whitelist resulthint protocols
|
||||||
|
bool fromQuery = false;
|
||||||
if ( !e->query()->results().isEmpty() )
|
if ( !e->query()->results().isEmpty() )
|
||||||
resultHint = e->query()->results().first()->url();
|
foundResult = e->query()->results().first()->url();
|
||||||
else if ( !e->query()->resultHint().isEmpty() )
|
else if ( !e->query()->resultHint().isEmpty() )
|
||||||
|
{
|
||||||
resultHint = e->query()->resultHint();
|
resultHint = e->query()->resultHint();
|
||||||
|
foundResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( resultHint.startsWith( "file://" ) ||
|
||||||
|
resultHint.startsWith( "servent://" ) || // Save resulthints for local files and peers automatically
|
||||||
|
( fromQuery && e->query()->saveHTTPResultHint() ) )
|
||||||
|
{
|
||||||
|
resultHint = foundResult;
|
||||||
|
}
|
||||||
|
|
||||||
adde.bindValue( 0, e->guid() );
|
adde.bindValue( 0, e->guid() );
|
||||||
adde.bindValue( 1, m_playlistguid );
|
adde.bindValue( 1, m_playlistguid );
|
||||||
|
@@ -621,17 +621,14 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Q_ASSERT( false );
|
// Q_ASSERT( false );
|
||||||
/* res = Tomahawk::result_ptr( new Tomahawk::Result() );
|
res = Tomahawk::Result::get( url );
|
||||||
s = SourceList::instance()->webSource();
|
|
||||||
res->setUrl( url );
|
|
||||||
res->setCollection( s->collection() );
|
|
||||||
res->setRID( uuid() );
|
res->setRID( uuid() );
|
||||||
res->setScore( 1.0 );
|
res->setScore( 1.0 );
|
||||||
res->setArtist( Tomahawk::artist_ptr( new Tomahawk::Artist( 0, origquery->artist() ) ) );
|
res->setArtist( Tomahawk::Artist::get( artistId( origquery->artist(), true ), origquery->artist() ) );
|
||||||
res->setAlbum( Tomahawk::album_ptr( new Tomahawk::Album( 0, origquery->album(), res->artist() ) ) );
|
res->setAlbum( Tomahawk::Album::get( albumId( res->artist()->id(), origquery->album(), true ), origquery->album(), res->artist() ) );
|
||||||
res->setTrack( origquery->track() );
|
res->setTrack( origquery->track() );
|
||||||
res->setDuration( origquery->duration() );
|
res->setDuration( origquery->duration() );
|
||||||
res->setFriendlySource( url );*/
|
res->setFriendlySource( url );
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -179,7 +179,10 @@ JSPFLoader::gotBody()
|
|||||||
|
|
||||||
q->setDuration( duration.toInt() / 1000 );
|
q->setDuration( duration.toInt() / 1000 );
|
||||||
if( !url.isEmpty() )
|
if( !url.isEmpty() )
|
||||||
|
{
|
||||||
q->setResultHint( url );
|
q->setResultHint( url );
|
||||||
|
q->setSaveHTTPResultHint( true );
|
||||||
|
}
|
||||||
|
|
||||||
m_entries << q;
|
m_entries << q;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -250,7 +250,10 @@ XSPFLoader::gotBody()
|
|||||||
|
|
||||||
q->setDuration( duration.toInt() / 1000 );
|
q->setDuration( duration.toInt() / 1000 );
|
||||||
if ( !url.isEmpty() )
|
if ( !url.isEmpty() )
|
||||||
|
{
|
||||||
q->setResultHint( url );
|
q->setResultHint( url );
|
||||||
|
q->setSaveHTTPResultHint( true );
|
||||||
|
}
|
||||||
|
|
||||||
m_entries << q;
|
m_entries << q;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user