From 1d960d5da6fc714d573a19ce155099be8ca8bf14 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 2 Dec 2012 22:55:22 +0100 Subject: [PATCH] When passing tag on the command-line, replace certain characters that can be "problematic" on the command-line. --- src/Config.h | 2 +- src/Encoder_AAC.cpp | 10 +++++----- src/Encoder_AAC_QAAC.cpp | 10 +++++----- src/Encoder_Abstract.cpp | 11 +++++++++++ src/Encoder_Abstract.h | 1 + src/Encoder_FLAC.cpp | 10 +++++----- src/Encoder_MP3.cpp | 10 +++++----- src/Encoder_Opus.cpp | 10 +++++----- src/Encoder_Vorbis.cpp | 10 +++++----- 9 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/Config.h b/src/Config.h index 38f30737..9a71ff8c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 5 -#define VER_LAMEXP_BUILD 1200 +#define VER_LAMEXP_BUILD 1201 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Encoder_AAC.cpp b/src/Encoder_AAC.cpp index f7a696a7..35f85730 100644 --- a/src/Encoder_AAC.cpp +++ b/src/Encoder_AAC.cpp @@ -198,11 +198,11 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInf args.clear(); args << QDir::toNativeSeparators(outputFile); - if(!metaInfo.fileName().isEmpty()) args << QString("-meta:title=%1").arg(metaInfo.fileName()); - if(!metaInfo.fileArtist().isEmpty()) args << QString("-meta:artist=%1").arg(metaInfo.fileArtist()); - if(!metaInfo.fileAlbum().isEmpty()) args << QString("-meta:album=%1").arg(metaInfo.fileAlbum()); - if(!metaInfo.fileGenre().isEmpty()) args << QString("-meta:genre=%1").arg(metaInfo.fileGenre()); - if(!metaInfo.fileComment().isEmpty()) args << QString("-meta:comment=%1").arg(metaInfo.fileComment()); + if(!metaInfo.fileName().isEmpty()) args << QString("-meta:title=%1").arg(cleanTag(metaInfo.fileName())); + if(!metaInfo.fileArtist().isEmpty()) args << QString("-meta:artist=%1").arg(cleanTag(metaInfo.fileArtist())); + if(!metaInfo.fileAlbum().isEmpty()) args << QString("-meta:album=%1").arg(cleanTag(metaInfo.fileAlbum())); + if(!metaInfo.fileGenre().isEmpty()) args << QString("-meta:genre=%1").arg(cleanTag(metaInfo.fileGenre())); + 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.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()); diff --git a/src/Encoder_AAC_QAAC.cpp b/src/Encoder_AAC_QAAC.cpp index 4147d87f..83bb8fab 100644 --- a/src/Encoder_AAC_QAAC.cpp +++ b/src/Encoder_AAC_QAAC.cpp @@ -86,11 +86,11 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts); - if(!metaInfo.fileName().isEmpty()) args << "--title" << metaInfo.fileName(); - if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << metaInfo.fileArtist(); - if(!metaInfo.fileAlbum().isEmpty()) args << "--album" << metaInfo.fileAlbum(); - if(!metaInfo.fileGenre().isEmpty()) args << "--genre" << metaInfo.fileGenre(); - if(!metaInfo.fileComment().isEmpty()) args << "--comment" << metaInfo.fileComment(); + if(!metaInfo.fileName().isEmpty()) args << "--title" << cleanTag(metaInfo.fileName()); + if(!metaInfo.fileArtist().isEmpty()) args << "--artist" << cleanTag(metaInfo.fileArtist()); + if(!metaInfo.fileAlbum().isEmpty()) args << "--album" << cleanTag(metaInfo.fileAlbum()); + if(!metaInfo.fileGenre().isEmpty()) args << "--genre" << cleanTag(metaInfo.fileGenre()); + if(!metaInfo.fileComment().isEmpty()) args << "--comment" << cleanTag( metaInfo.fileComment()); if(metaInfo.fileYear()) args << "--date" << QString::number(metaInfo.fileYear()); if(metaInfo.filePosition()) args << "--track" << QString::number(metaInfo.filePosition()); if(!metaInfo.fileCover().isEmpty()) args << "--artwork" << metaInfo.fileCover(); diff --git a/src/Encoder_Abstract.cpp b/src/Encoder_Abstract.cpp index 0a0a3854..25b3b139 100644 --- a/src/Encoder_Abstract.cpp +++ b/src/Encoder_Abstract.cpp @@ -73,8 +73,19 @@ const bool AbstractEncoder::needsTimingInfo(void) /* * Helper functions */ + +//Does this text contain Non-ASCII characters? bool AbstractEncoder::isUnicode(const QString &original) { QString asLatin1 = QString::fromLatin1(original.toLatin1().constData()); 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; +} diff --git a/src/Encoder_Abstract.h b/src/Encoder_Abstract.h index abf04a5d..17f97b0b 100644 --- a/src/Encoder_Abstract.h +++ b/src/Encoder_Abstract.h @@ -57,4 +57,5 @@ protected: //Helper functions bool isUnicode(const QString &text); + QString cleanTag(const QString &text); }; diff --git a/src/Encoder_FLAC.cpp b/src/Encoder_FLAC.cpp index 0add2361..152328c5 100644 --- a/src/Encoder_FLAC.cpp +++ b/src/Encoder_FLAC.cpp @@ -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 << "--channel-map=none"; - if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(metaInfo.fileName()); - if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(metaInfo.fileArtist()); - if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(metaInfo.fileAlbum()); - if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(metaInfo.fileGenre()); - if(!metaInfo.fileComment().isEmpty()) args << "-T" << QString("comment=%1").arg(metaInfo.fileComment()); + if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(cleanTag(metaInfo.fileName())); + if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(cleanTag(metaInfo.fileArtist())); + if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(cleanTag(metaInfo.fileAlbum())); + if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(cleanTag(metaInfo.fileGenre())); + 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.filePosition()) args << "-T" << QString("track=%1").arg(QString::number(metaInfo.filePosition())); if(!metaInfo.fileCover().isEmpty()) args << QString("--picture=%1").arg(metaInfo.fileCover()); diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp index 9134858c..add40b5c 100644 --- a/src/Encoder_MP3.cpp +++ b/src/Encoder_MP3.cpp @@ -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(!metaInfo.fileName().isEmpty()) args << "--tt" << metaInfo.fileName(); - if(!metaInfo.fileArtist().isEmpty()) args << "--ta" << metaInfo.fileArtist(); - if(!metaInfo.fileAlbum().isEmpty()) args << "--tl" << metaInfo.fileAlbum(); - if(!metaInfo.fileGenre().isEmpty()) args << "--tg" << metaInfo.fileGenre(); - if(!metaInfo.fileComment().isEmpty()) args << "--tc" << metaInfo.fileComment(); + if(!metaInfo.fileName().isEmpty()) args << "--tt" << cleanTag(metaInfo.fileName()); + if(!metaInfo.fileArtist().isEmpty()) args << "--ta" << cleanTag(metaInfo.fileArtist()); + if(!metaInfo.fileAlbum().isEmpty()) args << "--tl" <