mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-02 10:24:01 +02:00
Allow resolving file:// directly
This commit is contained in:
@@ -614,11 +614,6 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
||||
if ( s.isNull() )
|
||||
return res;
|
||||
}
|
||||
else if ( url.contains( "file://" ) )
|
||||
{
|
||||
s = SourceList::instance()->getLocal();
|
||||
fileUrl = url;
|
||||
}
|
||||
else if ( TomahawkUtils::whitelistedHttpResultHint( url ) ||
|
||||
TomahawkUtils::whitelistedCustomProtocolResultHint( url ) )
|
||||
{
|
||||
|
@@ -24,6 +24,8 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include "Query.h"
|
||||
#include "utils/NetworkReply.h"
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -49,6 +51,15 @@ void
|
||||
CustomResultHintChecker::handleResultHint()
|
||||
{
|
||||
|
||||
if ( url().startsWith( "file:" ) )
|
||||
{
|
||||
QFileInfo tmpFile( QUrl::fromUserInput( url() ).toLocalFile() );
|
||||
if( !tmpFile.exists() )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << url();
|
||||
removeHint();
|
||||
}
|
||||
}
|
||||
if ( url().startsWith( "hnhh" ) )
|
||||
{
|
||||
QUrl httpUrl = QUrl::fromUserInput( url() );
|
||||
|
@@ -31,6 +31,7 @@
|
||||
/* taglib */
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/tag.h>
|
||||
#include "filemetadata/taghandlers/tag.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -77,12 +78,15 @@ M3uLoader::getTags( const QFileInfo& info )
|
||||
TagLib::FileRef f( encodedName );
|
||||
if( f.isNull() )
|
||||
return;
|
||||
TagLib::Tag *tag = f.tag();
|
||||
|
||||
Tag* tag = Tag::fromFile( f );
|
||||
if( !tag )
|
||||
return;
|
||||
QString artist = TStringToQString( tag->artist() ).trimmed();
|
||||
QString album = TStringToQString( tag->album() ).trimmed();
|
||||
QString track = TStringToQString( tag->title() ).trimmed();
|
||||
|
||||
QString artist, album, track;
|
||||
artist = tag->artist().trimmed();
|
||||
album = tag->album().trimmed();
|
||||
track = tag->title().trimmed();
|
||||
|
||||
if ( artist.isEmpty() || track.isEmpty() )
|
||||
{
|
||||
@@ -91,12 +95,21 @@ M3uLoader::getTags( const QFileInfo& info )
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << artist << track << album;
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
|
||||
if ( !q.isNull() )
|
||||
{
|
||||
q->setResultHint( "file://" + info.absoluteFilePath() );
|
||||
q->setSaveHTTPResultHint( true );
|
||||
|
||||
TagLib::AudioProperties *audioProp = f.audioProperties();
|
||||
if ( audioProp )
|
||||
{
|
||||
q->setDuration( audioProp->length() );
|
||||
}
|
||||
q->setComposer( tag->composer() );
|
||||
q->setAlbumPos( tag->track() );
|
||||
q->setDiscNumber( tag->discNumber() );
|
||||
|
||||
qDebug() << "Adding resulthint" << q->resultHint();
|
||||
m_tracks << q;
|
||||
}
|
||||
|
@@ -953,7 +953,7 @@ whitelistedHttpResultHint( const QString& url )
|
||||
bool
|
||||
whitelistedCustomProtocolResultHint( const QString& url )
|
||||
{
|
||||
return url.startsWith( "hnhh" );
|
||||
return url.startsWith( "hnhh" ) | url.startsWith( "file:" );
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
Reference in New Issue
Block a user