aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/General/converter/converter.cpp24
-rw-r--r--src/plugins/General/converter/converter.pro5
2 files changed, 26 insertions, 3 deletions
diff --git a/src/plugins/General/converter/converter.cpp b/src/plugins/General/converter/converter.cpp
index 441b97e09..6ecb6667c 100644
--- a/src/plugins/General/converter/converter.cpp
+++ b/src/plugins/General/converter/converter.cpp
@@ -25,10 +25,12 @@
#include <qmmp/metadatamanager.h>
#include <qmmpui/metadataformatter.h>
#include <QtEndian>
-#include <QSettings>
-#include <QDesktopServices>
+#include <taglib/fileref.h>
+#include <taglib/tag.h>
#include "converter.h"
+#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8)
+
Converter::Converter(QObject *parent) : QThread(parent)
{}
@@ -137,6 +139,7 @@ void Converter::run()
continue;
}
+ QMap<Qmmp::MetaData, QString> metadata = list[0]->metaData();
MetaDataFormatter formatter(pattern);
QString desc = tr("Track: %1").arg(desc_formatter.parse(list[0]->metaData(), list[0]->length()));
@@ -214,6 +217,23 @@ void Converter::run()
else
qDebug("Converter: task '%s' finished with success", qPrintable(preset["name"].toString()));
m_mutex.unlock();
+
+ if(preset["tags"].toBool())
+ {
+ qDebug("Converter: writing tags");
+ TagLib::FileRef file(qPrintable(full_path));
+ if(file.tag())
+ {
+ file.tag()->setTitle(QStringToTString_qt4(metadata[Qmmp::TITLE]));
+ file.tag()->setArtist(QStringToTString_qt4(metadata[Qmmp::ARTIST]));
+ file.tag()->setAlbum(QStringToTString_qt4(metadata[Qmmp::ALBUM]));
+ file.tag()->setGenre(QStringToTString_qt4(metadata[Qmmp::GENRE]));
+ file.tag()->setComment(QStringToTString_qt4(metadata[Qmmp::COMMENT]));
+ file.tag()->setYear(metadata[Qmmp::YEAR].toUInt());
+ file.tag()->setTrack(metadata[Qmmp::TRACK].toUInt());
+ file.save();
+ }
+ }
}
qDebug("Converter: thread finished");
}
diff --git a/src/plugins/General/converter/converter.pro b/src/plugins/General/converter/converter.pro
index c9588d508..66834b7ad 100644
--- a/src/plugins/General/converter/converter.pro
+++ b/src/plugins/General/converter/converter.pro
@@ -3,7 +3,8 @@ include(../../plugins.pri)
INCLUDEPATH += ../../../../src
CONFIG += release \
warn_on \
-plugin
+plugin \
+link_pkgconfig
TARGET =$$PLUGINS_PREFIX/General/converter
unix:QMAKE_CLEAN = $$PLUGINS_PREFIX/General/libconverter.so
@@ -13,6 +14,8 @@ TEMPLATE = lib
unix:QMAKE_LIBDIR += ../../../../lib
unix:LIBS += -lqmmpui -lqmmp
+PKGCONFIG += taglib
+
win32:QMAKE_LIBDIR += ../../../../bin
win32:LIBS += -lqmmpui0 -lqmmp0