More fixes for the Cue Sheet parser: Strings don't have to be enclosed in quotes, if they don't contain any whitespace chars, so we should support that case. Also generate a title from the track number, if the Cue Sheet doesn't define a title for the track.
This commit is contained in:
parent
466d339d9d
commit
9276645f1b
@ -538,44 +538,44 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>CueSheetModel</name>
|
<name>CueSheetModel</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="206"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="208"/>
|
||||||
<source>No.</source>
|
<source>No.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="209"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="211"/>
|
||||||
<source>File / Track</source>
|
<source>File / Track</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="212"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="214"/>
|
||||||
<source>Index</source>
|
<source>Index</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="215"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="217"/>
|
||||||
<source>Duration</source>
|
<source>Duration</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="241"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="243"/>
|
||||||
<source>File %1</source>
|
<source>File %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="256"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="258"/>
|
||||||
<source>Track %1</source>
|
<source>Track %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="265"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="267"/>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="273"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
|
||||||
<source>Unknown Artist</source>
|
<source>Unknown Artist</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="269"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="271"/>
|
||||||
<location filename="../../src/Model_CueSheet.cpp" line="273"/>
|
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
|
||||||
<source>Unknown Title</source>
|
<source>Unknown Title</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 3
|
#define VER_LAMEXP_MINOR_LO 3
|
||||||
#define VER_LAMEXP_TYPE Beta
|
#define VER_LAMEXP_TYPE Beta
|
||||||
#define VER_LAMEXP_PATCH 2
|
#define VER_LAMEXP_PATCH 2
|
||||||
#define VER_LAMEXP_BUILD 694
|
#define VER_LAMEXP_BUILD 696
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Tools versions
|
// Tools versions
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#define UNQUOTE(STR) STR.split("\"", QString::SkipEmptyParts).first().trimmed()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Helper Classes
|
// Helper Classes
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -561,12 +563,12 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
qDebug("Encoding is %s.", (bUTF8 ? "UTF-8" : "Local 8-Bit"));
|
qDebug("Encoding is %s.", (bUTF8 ? "UTF-8" : "Local 8-Bit"));
|
||||||
bomCheck.clear();
|
bomCheck.clear();
|
||||||
|
|
||||||
QRegExp rxFile("^FILE\\s+\"([^\"]+)\"\\s+(\\w+)$", Qt::CaseInsensitive);
|
QRegExp rxFile("^FILE\\s+(\"[^\"]+\"|\\S+)\\s+(\\w+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxTrack("^TRACK\\s+(\\d+)\\s(\\w+)$", Qt::CaseInsensitive);
|
QRegExp rxTrack("^TRACK\\s+(\\d+)\\s(\\w+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxIndex("^INDEX\\s+(\\d+)\\s+([0-9:]+)$", Qt::CaseInsensitive);
|
QRegExp rxIndex("^INDEX\\s+(\\d+)\\s+([0-9:]+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxTitle("^TITLE\\s+\"([^\"]+)\"$", Qt::CaseInsensitive);
|
QRegExp rxTitle("^TITLE\\s+(\"[^\"]+\"|\\S+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxPerformer("^PERFORMER\\s+\"([^\"]+)\"$", Qt::CaseInsensitive);
|
QRegExp rxPerformer("^PERFORMER\\s+(\"[^\"]+\"|\\S+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxGenre("^REM\\s+GENRE\\s+(\\w+)$", Qt::CaseInsensitive);
|
QRegExp rxGenre("^REM\\s+GENRE\\s+(\"[^\"]+\"|\\S+)$", Qt::CaseInsensitive);
|
||||||
QRegExp rxYear("^REM\\s+DATE\\s+(\\d+)$", Qt::CaseInsensitive);
|
QRegExp rxYear("^REM\\s+DATE\\s+(\\d+)$", Qt::CaseInsensitive);
|
||||||
|
|
||||||
bool bPreamble = true;
|
bool bPreamble = true;
|
||||||
@ -632,7 +634,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
}
|
}
|
||||||
if(!rxFile.cap(2).compare("WAVE", Qt::CaseInsensitive) || !rxFile.cap(2).compare("MP3", Qt::CaseInsensitive) || !rxFile.cap(2).compare("AIFF", Qt::CaseInsensitive))
|
if(!rxFile.cap(2).compare("WAVE", Qt::CaseInsensitive) || !rxFile.cap(2).compare("MP3", Qt::CaseInsensitive) || !rxFile.cap(2).compare("AIFF", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
currentFile = new CueSheetFile(baseDir.absoluteFilePath(rxFile.cap(1)));
|
currentFile = new CueSheetFile(baseDir.absoluteFilePath(UNQUOTE(rxFile.cap(1))));
|
||||||
qDebug("%03d File path: <%s>", lines, currentFile->fileName().toUtf8().constData());
|
qDebug("%03d File path: <%s>", lines, currentFile->fileName().toUtf8().constData());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -702,12 +704,12 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
{
|
{
|
||||||
if(bPreamble)
|
if(bPreamble)
|
||||||
{
|
{
|
||||||
m_albumTitle = rxTitle.cap(1).simplified();
|
m_albumTitle = UNQUOTE(rxTitle.cap(1)).simplified();
|
||||||
}
|
}
|
||||||
else if(currentFile && currentTrack)
|
else if(currentFile && currentTrack)
|
||||||
{
|
{
|
||||||
qDebug("%03d Title: <%s>", lines, rxTitle.cap(1).toUtf8().constData());
|
qDebug("%03d Title: <%s>", lines, rxTitle.cap(1).toUtf8().constData());
|
||||||
currentTrack->setTitle(rxTitle.cap(1).simplified());
|
currentTrack->setTitle(UNQUOTE(rxTitle.cap(1)).simplified());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -717,12 +719,12 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
{
|
{
|
||||||
if(bPreamble)
|
if(bPreamble)
|
||||||
{
|
{
|
||||||
m_albumPerformer = rxPerformer.cap(1).simplified();
|
m_albumPerformer = UNQUOTE(rxPerformer.cap(1)).simplified();
|
||||||
}
|
}
|
||||||
else if(currentFile && currentTrack)
|
else if(currentFile && currentTrack)
|
||||||
{
|
{
|
||||||
qDebug("%03d Title: <%s>", lines, rxPerformer.cap(1).toUtf8().constData());
|
qDebug("%03d Title: <%s>", lines, rxPerformer.cap(1).toUtf8().constData());
|
||||||
currentTrack->setPerformer(rxPerformer.cap(1).simplified());
|
currentTrack->setPerformer(UNQUOTE(rxPerformer.cap(1)).simplified());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -732,7 +734,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
{
|
{
|
||||||
if(bPreamble)
|
if(bPreamble)
|
||||||
{
|
{
|
||||||
QString temp = rxGenre.cap(1).simplified();
|
QString temp = UNQUOTE(rxGenre.cap(1)).simplified();
|
||||||
for(int i = 0; g_lamexp_generes[i]; i++)
|
for(int i = 0; g_lamexp_generes[i]; i++)
|
||||||
{
|
{
|
||||||
if(temp.compare(g_lamexp_generes[i], Qt::CaseInsensitive) == 0)
|
if(temp.compare(g_lamexp_generes[i], Qt::CaseInsensitive) == 0)
|
||||||
@ -745,7 +747,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
else if(currentFile && currentTrack)
|
else if(currentFile && currentTrack)
|
||||||
{
|
{
|
||||||
qDebug("%03d Genre: <%s>", lines, rxGenre.cap(1).toUtf8().constData());
|
qDebug("%03d Genre: <%s>", lines, rxGenre.cap(1).toUtf8().constData());
|
||||||
QString temp = rxGenre.cap(1).simplified();
|
QString temp = UNQUOTE(rxGenre.cap(1).simplified());
|
||||||
for(int i = 0; g_lamexp_generes[i]; i++)
|
for(int i = 0; g_lamexp_generes[i]; i++)
|
||||||
{
|
{
|
||||||
if(temp.compare(g_lamexp_generes[i], Qt::CaseInsensitive) == 0)
|
if(temp.compare(g_lamexp_generes[i], Qt::CaseInsensitive) == 0)
|
||||||
@ -831,12 +833,14 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
//Sanity check of track numbers
|
//Sanity check of track numbers
|
||||||
if(nFiles > 0)
|
if(nFiles > 0)
|
||||||
{
|
{
|
||||||
|
bool hasTracks = false;
|
||||||
int previousTrackNo = -1;
|
int previousTrackNo = -1;
|
||||||
bool trackNo[100];
|
bool trackNo[100];
|
||||||
for(int i = 0; i < 100; i++)
|
for(int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
trackNo[i] = false;
|
trackNo[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < nFiles; i++)
|
for(int i = 0; i < nFiles; i++)
|
||||||
{
|
{
|
||||||
if(application)
|
if(application)
|
||||||
@ -858,7 +862,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
}
|
}
|
||||||
if(currentTrackNo <= previousTrackNo)
|
if(currentTrackNo <= previousTrackNo)
|
||||||
{
|
{
|
||||||
qWarning("Non-increasing track numbers, Cue Sheet is inconsistent!", currentTrackNo);
|
qWarning("Non-increasing track numbers (%02d -> %02d), Cue Sheet is inconsistent!", previousTrackNo, currentTrackNo);
|
||||||
return ErrorInconsistent;
|
return ErrorInconsistent;
|
||||||
}
|
}
|
||||||
if(trackNo[currentTrackNo])
|
if(trackNo[currentTrackNo])
|
||||||
@ -868,13 +872,22 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
|
|||||||
}
|
}
|
||||||
trackNo[currentTrackNo] = true;
|
trackNo[currentTrackNo] = true;
|
||||||
previousTrackNo = currentTrackNo;
|
previousTrackNo = currentTrackNo;
|
||||||
|
hasTracks = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!hasTracks)
|
||||||
|
{
|
||||||
|
qWarning("Could not find at least one valid track in the Cue Sheet!");
|
||||||
|
return ErrorInconsistent;
|
||||||
|
}
|
||||||
|
|
||||||
return ErrorSuccess;
|
return ErrorSuccess;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qWarning("Could not find at least one valid input file in the Cue Sheet!");
|
||||||
return bUnsupportedTrack ? ErrorUnsupported : ErrorBadFile;
|
return bUnsupportedTrack ? ErrorUnsupported : ErrorBadFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,6 +181,10 @@ void CueSplitter::run()
|
|||||||
trackMetaInfo.setFilePosition(trackNo);
|
trackMetaInfo.setFilePosition(trackNo);
|
||||||
|
|
||||||
//Apply album meta data on files
|
//Apply album meta data on files
|
||||||
|
if(trackMetaInfo.fileName().trimmed().isEmpty())
|
||||||
|
{
|
||||||
|
trackMetaInfo.setFileName(QString().sprintf("Track %02d", trackNo));
|
||||||
|
}
|
||||||
if(!albumTitle.isEmpty())
|
if(!albumTitle.isEmpty())
|
||||||
{
|
{
|
||||||
trackMetaInfo.setFileAlbum(albumTitle);
|
trackMetaInfo.setFileAlbum(albumTitle);
|
||||||
|
Loading…
Reference in New Issue
Block a user