mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-17 14:28:24 +01:00
Add basic libvlc metadata usage
This commit is contained in:
parent
04b52d7273
commit
0d7c7a0ce3
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "MusicScanner.h"
|
#include "MusicScanner.h"
|
||||||
|
|
||||||
|
#include "audio/AudioOutput.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
#include "database/DatabaseCommand_DirMtimes.h"
|
#include "database/DatabaseCommand_DirMtimes.h"
|
||||||
#include "database/DatabaseCommand_FileMTimes.h"
|
#include "database/DatabaseCommand_FileMTimes.h"
|
||||||
@ -33,6 +34,9 @@
|
|||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
|
|
||||||
|
#include <vlc/libvlc.h>
|
||||||
|
#include <vlc/libvlc_media.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
@ -385,11 +389,68 @@ MusicScanner::scanFile( const QFileInfo& fi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
getVlcMeta( libvlc_media_t* media, libvlc_meta_t meta )
|
||||||
|
{
|
||||||
|
char* str = libvlc_media_get_meta( media, meta );
|
||||||
|
QString string = QString::fromUtf8( str );
|
||||||
|
free( str );
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
MusicScanner::readTags( const QFileInfo& fi )
|
MusicScanner::readTags( const QFileInfo& fi )
|
||||||
{
|
{
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Parsing tags for file:" << fi.absoluteFilePath();
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Parsing tags for file:" << fi.absoluteFilePath();
|
||||||
|
|
||||||
|
libvlc_media_t* media = libvlc_media_new_path( AudioOutput::instance()->vlcInstance(),
|
||||||
|
fi.canonicalFilePath().toUtf8().constData() );
|
||||||
|
tLog() << fi.canonicalFilePath().toUtf8().constData();
|
||||||
|
libvlc_media_parse( media );
|
||||||
|
|
||||||
|
QString url( "file://%1" );
|
||||||
|
QVariantMap m;
|
||||||
|
m["url"] = url.arg( fi.canonicalFilePath() );
|
||||||
|
m["mtime"] = fi.lastModified().toUTC().toTime_t();
|
||||||
|
m["size"] = (unsigned int)fi.size();
|
||||||
|
/* m["mimetype"] = mimetype;
|
||||||
|
m["duration"] = duration;
|
||||||
|
m["bitrate"] = bitrate; */
|
||||||
|
|
||||||
|
m["artist"] = getVlcMeta( media, libvlc_meta_Artist );
|
||||||
|
m["album"] = getVlcMeta( media, libvlc_meta_Album );
|
||||||
|
m["track"] = getVlcMeta( media, libvlc_meta_Title );
|
||||||
|
m["albumpos"] = getVlcMeta( media, libvlc_meta_TrackNumber ).toInt();
|
||||||
|
m["year"] = getVlcMeta( media, libvlc_meta_Date ).toInt();
|
||||||
|
// m["albumartist"] = tag->albumArtist();
|
||||||
|
// m["composer"] = tag->composer();
|
||||||
|
// m["discnumber"] = tag->discNumber();
|
||||||
|
// m["hash"] = ""; // TODO
|
||||||
|
/*
|
||||||
|
libvlc_meta_Genre,
|
||||||
|
libvlc_meta_Copyright,
|
||||||
|
libvlc_meta_TrackNumber,
|
||||||
|
libvlc_meta_Description,
|
||||||
|
libvlc_meta_Rating,
|
||||||
|
libvlc_meta_Setting,
|
||||||
|
libvlc_meta_URL,
|
||||||
|
libvlc_meta_Language,
|
||||||
|
libvlc_meta_NowPlaying,
|
||||||
|
libvlc_meta_Publisher,
|
||||||
|
libvlc_meta_EncodedBy,
|
||||||
|
libvlc_meta_ArtworkURL,
|
||||||
|
libvlc_meta_TrackID,
|
||||||
|
libvlc_meta_TrackTotal,
|
||||||
|
libvlc_meta_Director,
|
||||||
|
libvlc_meta_Season,
|
||||||
|
libvlc_meta_Episode,
|
||||||
|
libvlc_meta_ShowName,
|
||||||
|
libvlc_meta_Actors
|
||||||
|
*/
|
||||||
|
|
||||||
|
libvlc_media_release( media );
|
||||||
|
|
||||||
|
|
||||||
const QString suffix = fi.suffix().toLower();
|
const QString suffix = fi.suffix().toLower();
|
||||||
if ( !TomahawkUtils::supportedExtensions().contains( suffix ) )
|
if ( !TomahawkUtils::supportedExtensions().contains( suffix ) )
|
||||||
return QVariantMap(); // invalid extension
|
return QVariantMap(); // invalid extension
|
||||||
@ -426,9 +487,7 @@ MusicScanner::readTags( const QFileInfo& fi )
|
|||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
|
|
||||||
QString mimetype = TomahawkUtils::extensionToMimetype( suffix );
|
QString mimetype = TomahawkUtils::extensionToMimetype( suffix );
|
||||||
QString url( "file://%1" );
|
|
||||||
|
|
||||||
QVariantMap m;
|
|
||||||
m["url"] = url.arg( fi.canonicalFilePath() );
|
m["url"] = url.arg( fi.canonicalFilePath() );
|
||||||
m["mtime"] = fi.lastModified().toUTC().toTime_t();
|
m["mtime"] = fi.lastModified().toUTC().toTime_t();
|
||||||
m["size"] = (unsigned int)fi.size();
|
m["size"] = (unsigned int)fi.size();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "audio/AudioOutput.h"
|
||||||
#include "filemetadata/MusicScanner.h"
|
#include "filemetadata/MusicScanner.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -41,6 +42,8 @@ main( int argc, char* argv[] )
|
|||||||
qRegisterMetaType< QDir >( "QDir" );
|
qRegisterMetaType< QDir >( "QDir" );
|
||||||
qRegisterMetaType< QFileInfo >( "QFileInfo" );
|
qRegisterMetaType< QFileInfo >( "QFileInfo" );
|
||||||
|
|
||||||
|
AudioOutput* aout = new AudioOutput();
|
||||||
|
|
||||||
// Create the MusicScanner instance
|
// Create the MusicScanner instance
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
paths << pathInfo.canonicalFilePath();
|
paths << pathInfo.canonicalFilePath();
|
||||||
@ -61,6 +64,8 @@ main( int argc, char* argv[] )
|
|||||||
|
|
||||||
// Wait until the scanner has done its work.
|
// Wait until the scanner has done its work.
|
||||||
scannerThread.wait();
|
scannerThread.wait();
|
||||||
|
|
||||||
|
delete aout;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user