Improved handling of different character encodings for M3U(8) and PLS playlist import.

This commit is contained in:
LoRd_MuldeR 2011-12-09 00:34:07 +01:00
parent 6e819e45b3
commit 545b9b4967
3 changed files with 48 additions and 48 deletions

View File

@ -22,6 +22,7 @@ a:visited { color: #0000EE; }
<li>Updated MediaInfo to v0.7.51+ (2011-11-19), compiled with ICL 12.1.6 and MSVC 10.0 <li>Updated MediaInfo to v0.7.51+ (2011-11-19), compiled with ICL 12.1.6 and MSVC 10.0
<li>Implemented coalescing of update signals to reduce the CPU usage of the LameXP process (<a href="http://forum.doom9.org/showpost.php?p=1539631&postcount=507" target="_blank">details</a>) <li>Implemented coalescing of update signals to reduce the CPU usage of the LameXP process (<a href="http://forum.doom9.org/showpost.php?p=1539631&postcount=507" target="_blank">details</a>)
<li>Run more than four instances in parallel on systems with more than four CPU cores (<a href="FAQ.html#89cbd3d0" target="_blank">details</a>) <li>Run more than four instances in parallel on systems with more than four CPU cores (<a href="FAQ.html#89cbd3d0" target="_blank">details</a>)
<li>Improved handling of different character encodings for Playlist and Cue Sheet import
<li>Workaround for a bug that causes MediaInfo to not detect the duration of Wave files (64-Bit only) <li>Workaround for a bug that causes MediaInfo to not detect the duration of Wave files (64-Bit only)
</ul><br> </ul><br>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 7 #define VER_LAMEXP_PATCH 7
#define VER_LAMEXP_BUILD 802 #define VER_LAMEXP_BUILD 803
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -132,32 +132,40 @@ PlaylistImporter::playlist_t PlaylistImporter::isPlaylist(const QString &fileNam
bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, const QDir &baseDir, const QDir &rootDir) bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, const QDir &baseDir, const QDir &rootDir)
{ {
QByteArray line = data.readLine(); QByteArray line = data.readLine();
const bool preferUTF8 = data.fileName().endsWith(".m3u8", Qt::CaseInsensitive);
while(line.size() > 0) while(line.size() > 0)
{ {
QFileInfo filename1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed())); QString filePath[3];
QFileInfo filename2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filename1.setCaching(false); if(preferUTF8)
filename2.setCaching(false);
if(!(filename1.filePath().startsWith("#") || filename2.filePath().startsWith("#")))
{ {
fixFilePath(filename1, baseDir, rootDir); filePath[0] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
fixFilePath(filename2, baseDir, rootDir); filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
}
else
{
filePath[0] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
}
if(filename1.exists()) for(size_t i = 0; i < 3; i++)
{
if(!(filePath[i].startsWith("#") || filePath[i].contains(QChar(QChar::ReplacementCharacter))))
{ {
if(isPlaylist(filename1.canonicalFilePath()) == notPlaylist) QFileInfo filename(filePath[i]);
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists())
{ {
fileList << filename1.canonicalFilePath(); if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
} {
} fileList << filename.canonicalFilePath();
else if(filename2.exists()) }
{ break;
if(isPlaylist(filename2.canonicalFilePath()) == notPlaylist)
{
fileList << filename2.canonicalFilePath();
} }
} }
} }
@ -175,40 +183,31 @@ bool PlaylistImporter::parsePlaylist_pls(QFile &data, QStringList &fileList, con
while(line.size() > 0) while(line.size() > 0)
{ {
bool flag = false; QString filePath[3];
QString temp1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
QString temp2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
if(!flag && plsEntry.indexIn(temp1) >= 0) filePath[0] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
for(size_t i = 0; i < 3; i++)
{ {
QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed()); if(!filePath[i].contains(QChar(QChar::ReplacementCharacter)))
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists())
{ {
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist) if(plsEntry.indexIn(filePath[i]) >= 0)
{ {
fileList << filename.canonicalFilePath(); QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed());
} filename.setCaching(false);
flag = true; fixFilePath(filename, baseDir, rootDir);
}
}
if(!flag && plsEntry.indexIn(temp2) >= 0)
{
QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed());
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists()) if(filename.exists())
{ {
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist) if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{ {
fileList << filename.canonicalFilePath(); fileList << filename.canonicalFilePath();
}
break;
}
} }
flag = true;
} }
} }