When passing tag on the command-line, replace certain characters that can be "problematic" on the command-line.

This commit is contained in:
LoRd_MuldeR 2012-12-02 22:55:22 +01:00
parent 799b73c258
commit 1d960d5da6
9 changed files with 43 additions and 31 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_MINOR_LO 7
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 5 #define VER_LAMEXP_PATCH 5
#define VER_LAMEXP_BUILD 1200 #define VER_LAMEXP_BUILD 1201
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -198,11 +198,11 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInf
args.clear(); args.clear();
args << QDir::toNativeSeparators(outputFile); args << QDir::toNativeSeparators(outputFile);
if(!metaInfo.fileName().isEmpty()) args << QString("-meta:title=%1").arg(metaInfo.fileName()); if(!metaInfo.fileName().isEmpty()) args << QString("-meta:title=%1").arg(cleanTag(metaInfo.fileName()));
if(!metaInfo.fileArtist().isEmpty()) args << QString("-meta:artist=%1").arg(metaInfo.fileArtist()); if(!metaInfo.fileArtist().isEmpty()) args << QString("-meta:artist=%1").arg(cleanTag(metaInfo.fileArtist()));
if(!metaInfo.fileAlbum().isEmpty()) args << QString("-meta:album=%1").arg(metaInfo.fileAlbum()); if(!metaInfo.fileAlbum().isEmpty()) args << QString("-meta:album=%1").arg(cleanTag(metaInfo.fileAlbum()));
if(!metaInfo.fileGenre().isEmpty()) args << QString("-meta:genre=%1").arg(metaInfo.fileGenre()); if(!metaInfo.fileGenre().isEmpty()) args << QString("-meta:genre=%1").arg(cleanTag(metaInfo.fileGenre()));
if(!metaInfo.fileComment().isEmpty()) args << QString("-meta:comment=%1").arg(metaInfo.fileComment()); if(!metaInfo.fileComment().isEmpty()) args << QString("-meta:comment=%1").arg(cleanTag(metaInfo.fileComment()));
if(metaInfo.fileYear()) args << QString("-meta:year=%1").arg(QString::number(metaInfo.fileYear())); if(metaInfo.fileYear()) args << QString("-meta:year=%1").arg(QString::number(metaInfo.fileYear()));
if(metaInfo.filePosition()) args << QString("-meta:track=%1").arg(QString::number(metaInfo.filePosition())); if(metaInfo.filePosition()) args << QString("-meta:track=%1").arg(QString::number(metaInfo.filePosition()));
if(!metaInfo.fileCover().isEmpty()) args << QString("-add-cover:%1:%2").arg("front", metaInfo.fileCover()); if(!metaInfo.fileCover().isEmpty()) args << QString("-add-cover:%1:%2").arg("front", metaInfo.fileCover());

View File

@ -86,11 +86,11 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn
if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts); if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts);
if(!metaInfo.fileName().isEmpty()) args << "--title" << metaInfo.fileName(); if(!metaInfo.fileName().isEmpty()) args << "--title" << cleanTag(metaInfo.fileName());
if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << metaInfo.fileArtist(); if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << cleanTag(metaInfo.fileArtist());
if(!metaInfo.fileAlbum().isEmpty()) args << "--album" << metaInfo.fileAlbum(); if(!metaInfo.fileAlbum().isEmpty()) args << "--album" << cleanTag(metaInfo.fileAlbum());
if(!metaInfo.fileGenre().isEmpty()) args << "--genre" << metaInfo.fileGenre(); if(!metaInfo.fileGenre().isEmpty()) args << "--genre" << cleanTag(metaInfo.fileGenre());
if(!metaInfo.fileComment().isEmpty()) args << "--comment" << metaInfo.fileComment(); if(!metaInfo.fileComment().isEmpty()) args << "--comment" << cleanTag( metaInfo.fileComment());
if(metaInfo.fileYear()) args << "--date" << QString::number(metaInfo.fileYear()); if(metaInfo.fileYear()) args << "--date" << QString::number(metaInfo.fileYear());
if(metaInfo.filePosition()) args << "--track" << QString::number(metaInfo.filePosition()); if(metaInfo.filePosition()) args << "--track" << QString::number(metaInfo.filePosition());
if(!metaInfo.fileCover().isEmpty()) args << "--artwork" << metaInfo.fileCover(); if(!metaInfo.fileCover().isEmpty()) args << "--artwork" << metaInfo.fileCover();

View File

@ -73,8 +73,19 @@ const bool AbstractEncoder::needsTimingInfo(void)
/* /*
* Helper functions * Helper functions
*/ */
//Does this text contain Non-ASCII characters?
bool AbstractEncoder::isUnicode(const QString &original) bool AbstractEncoder::isUnicode(const QString &original)
{ {
QString asLatin1 = QString::fromLatin1(original.toLatin1().constData()); QString asLatin1 = QString::fromLatin1(original.toLatin1().constData());
return (wcscmp(QWCHAR(original), QWCHAR(asLatin1)) != 0); return (wcscmp(QWCHAR(original), QWCHAR(asLatin1)) != 0);
} }
//Remove "problematic" characters from tag
QString AbstractEncoder::cleanTag(const QString &text)
{
QString result(text);
result.replace(QChar('"'), "'");
result.replace(QChar('\\'), "/");
return result;
}

View File

@ -57,4 +57,5 @@ protected:
//Helper functions //Helper functions
bool isUnicode(const QString &text); bool isUnicode(const QString &text);
QString cleanTag(const QString &text);
}; };

View File

@ -49,11 +49,11 @@ bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn
args << QString("-%1").arg(QString::number(qMax(0, qMin(8, m_configBitrate)))); args << QString("-%1").arg(QString::number(qMax(0, qMin(8, m_configBitrate))));
args << "--channel-map=none"; args << "--channel-map=none";
if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(metaInfo.fileName()); if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(cleanTag(metaInfo.fileName()));
if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(metaInfo.fileArtist()); if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(cleanTag(metaInfo.fileArtist()));
if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(metaInfo.fileAlbum()); if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(cleanTag(metaInfo.fileAlbum()));
if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(metaInfo.fileGenre()); if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(cleanTag(metaInfo.fileGenre()));
if(!metaInfo.fileComment().isEmpty()) args << "-T" << QString("comment=%1").arg(metaInfo.fileComment()); if(!metaInfo.fileComment().isEmpty()) args << "-T" << QString("comment=%1").arg(cleanTag(metaInfo.fileComment()));
if(metaInfo.fileYear()) args << "-T" << QString("date=%1").arg(QString::number(metaInfo.fileYear())); if(metaInfo.fileYear()) args << "-T" << QString("date=%1").arg(QString::number(metaInfo.fileYear()));
if(metaInfo.filePosition()) args << "-T" << QString("track=%1").arg(QString::number(metaInfo.filePosition())); if(metaInfo.filePosition()) args << "-T" << QString("track=%1").arg(QString::number(metaInfo.filePosition()));
if(!metaInfo.fileCover().isEmpty()) args << QString("--picture=%1").arg(metaInfo.fileCover()); if(!metaInfo.fileCover().isEmpty()) args << QString("--picture=%1").arg(metaInfo.fileCover());

View File

@ -118,11 +118,11 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel &metaInf
if(bUseUCS2) args << "--id3v2-ucs2"; //Must specify this BEFORE "--tt" and friends! if(bUseUCS2) args << "--id3v2-ucs2"; //Must specify this BEFORE "--tt" and friends!
if(!metaInfo.fileName().isEmpty()) args << "--tt" << metaInfo.fileName(); if(!metaInfo.fileName().isEmpty()) args << "--tt" << cleanTag(metaInfo.fileName());
if(!metaInfo.fileArtist().isEmpty()) args << "--ta" << metaInfo.fileArtist(); if(!metaInfo.fileArtist().isEmpty()) args << "--ta" << cleanTag(metaInfo.fileArtist());
if(!metaInfo.fileAlbum().isEmpty()) args << "--tl" << metaInfo.fileAlbum(); if(!metaInfo.fileAlbum().isEmpty()) args << "--tl" <<cleanTag( metaInfo.fileAlbum());
if(!metaInfo.fileGenre().isEmpty()) args << "--tg" << metaInfo.fileGenre(); if(!metaInfo.fileGenre().isEmpty()) args << "--tg" << cleanTag(metaInfo.fileGenre());
if(!metaInfo.fileComment().isEmpty()) args << "--tc" << metaInfo.fileComment(); if(!metaInfo.fileComment().isEmpty()) args << "--tc" << cleanTag(metaInfo.fileComment());
if(metaInfo.fileYear()) args << "--ty" << QString::number(metaInfo.fileYear()); if(metaInfo.fileYear()) args << "--ty" << QString::number(metaInfo.fileYear());
if(metaInfo.filePosition()) args << "--tn" << QString::number(metaInfo.filePosition()); if(metaInfo.filePosition()) args << "--tn" << QString::number(metaInfo.filePosition());
if(!metaInfo.fileCover().isEmpty()) args << "--ti" << QDir::toNativeSeparators(metaInfo.fileCover()); if(!metaInfo.fileCover().isEmpty()) args << "--ti" << QDir::toNativeSeparators(metaInfo.fileCover());

View File

@ -105,11 +105,11 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn
args << QString("--bitrate") << QString::number(qMax(0, qMin(500, m_configBitrate * 8))); args << QString("--bitrate") << QString::number(qMax(0, qMin(500, m_configBitrate * 8)));
if(!metaInfo.fileName().isEmpty()) args << "--title" << metaInfo.fileName(); if(!metaInfo.fileName().isEmpty()) args << "--title" << cleanTag(metaInfo.fileName());
if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << metaInfo.fileArtist(); if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << cleanTag(metaInfo.fileArtist());
if(!metaInfo.fileAlbum().isEmpty()) args << "--comment" << QString("album=%1").arg(metaInfo.fileAlbum()); if(!metaInfo.fileAlbum().isEmpty()) args << "--comment" << QString("album=%1").arg(cleanTag(metaInfo.fileAlbum()));
if(!metaInfo.fileGenre().isEmpty()) args << "--comment" << QString("genre=%1").arg(metaInfo.fileGenre()); if(!metaInfo.fileGenre().isEmpty()) args << "--comment" << QString("genre=%1").arg(cleanTag(metaInfo.fileGenre()));
if(!metaInfo.fileComment().isEmpty()) args << "--comment" << QString("comment=%1").arg(metaInfo.fileComment()); if(!metaInfo.fileComment().isEmpty()) args << "--comment" << QString("comment=%1").arg(cleanTag(metaInfo.fileComment()));
if(metaInfo.fileYear()) args << "--comment" << QString("date=%1").arg(QString::number(metaInfo.fileYear())); if(metaInfo.fileYear()) args << "--comment" << QString("date=%1").arg(QString::number(metaInfo.fileYear()));
if(metaInfo.filePosition()) args << "--comment" << QString("track=%1").arg(QString::number(metaInfo.filePosition())); if(metaInfo.filePosition()) args << "--comment" << QString("track=%1").arg(QString::number(metaInfo.filePosition()));

View File

@ -75,11 +75,11 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
args << "--resample" << QString::number(m_configSamplingRate) << "--converter" << QString::number(0); args << "--resample" << QString::number(m_configSamplingRate) << "--converter" << QString::number(0);
} }
if(!metaInfo.fileName().isEmpty()) args << "-t" << metaInfo.fileName(); if(!metaInfo.fileName().isEmpty()) args << "-t" << cleanTag(metaInfo.fileName());
if(!metaInfo.fileArtist().isEmpty()) args << "-a" << metaInfo.fileArtist(); if(!metaInfo.fileArtist().isEmpty()) args << "-a" << cleanTag(metaInfo.fileArtist());
if(!metaInfo.fileAlbum().isEmpty()) args << "-l" << metaInfo.fileAlbum(); if(!metaInfo.fileAlbum().isEmpty()) args << "-l" << cleanTag(metaInfo.fileAlbum());
if(!metaInfo.fileGenre().isEmpty()) args << "-G" << metaInfo.fileGenre(); if(!metaInfo.fileGenre().isEmpty()) args << "-G" << cleanTag(metaInfo.fileGenre());
if(!metaInfo.fileComment().isEmpty()) args << "-c" << QString("comment=%1").arg(metaInfo.fileComment()); if(!metaInfo.fileComment().isEmpty()) args << "-c" << QString("comment=%1").arg(cleanTag(metaInfo.fileComment()));
if(metaInfo.fileYear()) args << "-d" << QString::number(metaInfo.fileYear()); if(metaInfo.fileYear()) args << "-d" << QString::number(metaInfo.fileYear());
if(metaInfo.filePosition()) args << "-N" << QString::number(metaInfo.filePosition()); if(metaInfo.filePosition()) args << "-N" << QString::number(metaInfo.filePosition());