mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Added extensionToMimetype() to TomahawkUtils. ScriptResolver results now either need a mimetype or an extension.
This commit is contained in:
@@ -227,6 +227,26 @@ filesizeToString( unsigned int size )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
extensionToMimetype( const QString& extension )
|
||||||
|
{
|
||||||
|
static QMap<QString, QString> s_ext2mime;
|
||||||
|
if ( s_ext2mime.isEmpty() )
|
||||||
|
{
|
||||||
|
s_ext2mime.insert( "mp3", "audio/mpeg" );
|
||||||
|
s_ext2mime.insert( "ogg", "application/ogg" );
|
||||||
|
s_ext2mime.insert( "flac", "audio/flac" );
|
||||||
|
s_ext2mime.insert( "mpc", "audio/x-musepack" );
|
||||||
|
s_ext2mime.insert( "wma", "audio/x-ms-wma" );
|
||||||
|
s_ext2mime.insert( "aac", "audio/mp4" );
|
||||||
|
s_ext2mime.insert( "m4a", "audio/mp4" );
|
||||||
|
s_ext2mime.insert( "mp4", "audio/mp4" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_ext2mime.value( extension, "unknown" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
createDragPixmap( int itemCount )
|
createDragPixmap( int itemCount )
|
||||||
{
|
{
|
||||||
|
@@ -69,6 +69,7 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT QString timeToString( int seconds );
|
DLLEXPORT QString timeToString( int seconds );
|
||||||
DLLEXPORT QString ageToString( const QDateTime& time );
|
DLLEXPORT QString ageToString( const QDateTime& time );
|
||||||
DLLEXPORT QString filesizeToString( unsigned int size );
|
DLLEXPORT QString filesizeToString( unsigned int size );
|
||||||
|
DLLEXPORT QString extensionToMimetype( const QString& extension );
|
||||||
|
|
||||||
DLLEXPORT QPixmap createDragPixmap( int itemCount = 1 );
|
DLLEXPORT QPixmap createDragPixmap( int itemCount = 1 );
|
||||||
|
|
||||||
|
@@ -59,19 +59,14 @@ MusicScanner::MusicScanner( const QString& dir, quint32 bs )
|
|||||||
, m_dirLister( 0 )
|
, m_dirLister( 0 )
|
||||||
, m_dirListerThreadController( 0 )
|
, m_dirListerThreadController( 0 )
|
||||||
{
|
{
|
||||||
m_ext2mime.insert( "mp3", "audio/mpeg" );
|
m_ext2mime.insert( "mp3", TomahawkUtils::extensionToMimetype( "mp3" ) );
|
||||||
|
|
||||||
#ifndef NO_OGG
|
#ifndef NO_OGG
|
||||||
m_ext2mime.insert( "ogg", "application/ogg" );
|
m_ext2mime.insert( "ogg", TomahawkUtils::extensionToMimetype( "ogg" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_FLAC
|
#ifndef NO_FLAC
|
||||||
m_ext2mime.insert( "flac", "audio/flac" );
|
m_ext2mime.insert( "flac", TomahawkUtils::extensionToMimetype( "flac" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// m_ext2mime.insert( "aac", "audio/mp4" );
|
|
||||||
// m_ext2mime.insert( "m4a", "audio/mp4" );
|
|
||||||
// m_ext2mime.insert( "mp4", "audio/mp4" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
#include "functimeout.h"
|
#include "functimeout.h"
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
|
|
||||||
ScriptResolver::ScriptResolver( const QString& exe )
|
ScriptResolver::ScriptResolver( const QString& exe )
|
||||||
@@ -132,10 +133,17 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
|||||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||||
rp->setUrl( m.value( "url" ).toString() );
|
rp->setUrl( m.value( "url" ).toString() );
|
||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setMimetype( m.value( "mimetype" ).toString() );
|
|
||||||
rp->setScore( m.value( "score" ).toFloat() * ( (float)weight() / 100.0 ) );
|
rp->setScore( m.value( "score" ).toFloat() * ( (float)weight() / 100.0 ) );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( m_name );
|
rp->setFriendlySource( m_name );
|
||||||
|
|
||||||
|
rp->setMimetype( m.value( "mimetype" ).toString() );
|
||||||
|
if ( rp->mimetype().isEmpty() )
|
||||||
|
{
|
||||||
|
rp->setMimetype( TomahawkUtils::extensionToMimetype( m.value( "extension" ).toString() ) );
|
||||||
|
Q_ASSERT( !rp->mimetype().isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
results << rp;
|
results << rp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user