mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +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;
|
||||
|
||||
if ( !urlStr.isEmpty() )
|
||||
{
|
||||
q->setResultHint( urlStr );
|
||||
Pipeline::instance()->resolve( q );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
}
|
||||
|
||||
Pipeline::instance()->resolve( q, true );
|
||||
|
||||
handleOpenTrack( q );
|
||||
return true;
|
||||
@@ -668,9 +672,14 @@ GlobalActionManager::doQueueAdd( const QStringList& parts, const QList< QPair< Q
|
||||
{ // give it a web result hint
|
||||
QFileInfo info( track.path() );
|
||||
query_ptr q = Query::get( QString(), info.baseName(), QString(), uuid(), false );
|
||||
|
||||
if ( q.isNull() )
|
||||
continue;
|
||||
|
||||
q->setResultHint( track.toString() );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
|
||||
|
||||
q->setResultHint( track.toString() );
|
||||
Pipeline::instance()->resolve( q );
|
||||
|
||||
@@ -1075,7 +1084,10 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
|
||||
return false;
|
||||
|
||||
if ( !urlStr.isEmpty() )
|
||||
{
|
||||
q->setResultHint( urlStr );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
}
|
||||
|
||||
playNow( q );
|
||||
return true;
|
||||
@@ -1166,8 +1178,11 @@ bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
||||
return false;
|
||||
|
||||
if ( !urlStr.isEmpty() )
|
||||
{
|
||||
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
|
||||
QSharedPointer< LocalCollection > col = SourceList::instance()->getLocal()->collection().dynamicCast< LocalCollection >();
|
||||
|
@@ -164,6 +164,7 @@ Query::init()
|
||||
m_duration = -1;
|
||||
m_albumpos = 0;
|
||||
m_discnumber = 0;
|
||||
m_saveResultHint = false;
|
||||
|
||||
updateSortNames();
|
||||
}
|
||||
|
@@ -164,6 +164,9 @@ public:
|
||||
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
|
||||
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;
|
||||
QStringList lyrics() const;
|
||||
|
||||
@@ -254,6 +257,8 @@ private:
|
||||
QPair< Tomahawk::source_ptr, unsigned int > m_playedBy;
|
||||
QList< QWeakPointer< Tomahawk::Resolver > > m_resolvers;
|
||||
|
||||
bool m_saveResultHint;
|
||||
|
||||
mutable QMutex m_mutex;
|
||||
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();
|
||||
|
||||
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;
|
||||
res << result;
|
||||
|
@@ -199,11 +199,23 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
||||
|
||||
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() )
|
||||
resultHint = e->query()->results().first()->url();
|
||||
foundResult = e->query()->results().first()->url();
|
||||
else if ( !e->query()->resultHint().isEmpty() )
|
||||
{
|
||||
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( 1, m_playlistguid );
|
||||
|
@@ -621,17 +621,14 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
||||
else
|
||||
{
|
||||
// Q_ASSERT( false );
|
||||
/* res = Tomahawk::result_ptr( new Tomahawk::Result() );
|
||||
s = SourceList::instance()->webSource();
|
||||
res->setUrl( url );
|
||||
res->setCollection( s->collection() );
|
||||
res = Tomahawk::Result::get( url );
|
||||
res->setRID( uuid() );
|
||||
res->setScore( 1.0 );
|
||||
res->setArtist( Tomahawk::artist_ptr( new Tomahawk::Artist( 0, origquery->artist() ) ) );
|
||||
res->setAlbum( Tomahawk::album_ptr( new Tomahawk::Album( 0, origquery->album(), res->artist() ) ) );
|
||||
res->setArtist( Tomahawk::Artist::get( artistId( origquery->artist(), true ), origquery->artist() ) );
|
||||
res->setAlbum( Tomahawk::Album::get( albumId( res->artist()->id(), origquery->album(), true ), origquery->album(), res->artist() ) );
|
||||
res->setTrack( origquery->track() );
|
||||
res->setDuration( origquery->duration() );
|
||||
res->setFriendlySource( url );*/
|
||||
res->setFriendlySource( url );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@@ -179,7 +179,10 @@ JSPFLoader::gotBody()
|
||||
|
||||
q->setDuration( duration.toInt() / 1000 );
|
||||
if( !url.isEmpty() )
|
||||
{
|
||||
q->setResultHint( url );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
}
|
||||
|
||||
m_entries << q;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@@ -250,7 +250,10 @@ XSPFLoader::gotBody()
|
||||
|
||||
q->setDuration( duration.toInt() / 1000 );
|
||||
if ( !url.isEmpty() )
|
||||
{
|
||||
q->setResultHint( url );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
}
|
||||
|
||||
m_entries << q;
|
||||
}
|
||||
|
Reference in New Issue
Block a user