Improved handling of different character encodings for M3U(8) and PLS playlist import.
This commit is contained in:
parent
6e819e45b3
commit
545b9b4967
@ -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>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>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)
|
||||
</ul><br>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 4
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 7
|
||||
#define VER_LAMEXP_BUILD 802
|
||||
#define VER_LAMEXP_BUILD 803
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tool versions (minimum expected versions!)
|
||||
|
@ -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)
|
||||
{
|
||||
QByteArray line = data.readLine();
|
||||
|
||||
const bool preferUTF8 = data.fileName().endsWith(".m3u8", Qt::CaseInsensitive);
|
||||
|
||||
while(line.size() > 0)
|
||||
{
|
||||
QFileInfo filename1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
|
||||
QFileInfo filename2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
|
||||
QString filePath[3];
|
||||
|
||||
filename1.setCaching(false);
|
||||
filename2.setCaching(false);
|
||||
|
||||
if(!(filename1.filePath().startsWith("#") || filename2.filePath().startsWith("#")))
|
||||
if(preferUTF8)
|
||||
{
|
||||
fixFilePath(filename1, baseDir, rootDir);
|
||||
fixFilePath(filename2, baseDir, rootDir);
|
||||
filePath[0] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
|
||||
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();
|
||||
}
|
||||
}
|
||||
else if(filename2.exists())
|
||||
{
|
||||
if(isPlaylist(filename2.canonicalFilePath()) == notPlaylist)
|
||||
{
|
||||
fileList << filename2.canonicalFilePath();
|
||||
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,40 +183,31 @@ bool PlaylistImporter::parsePlaylist_pls(QFile &data, QStringList &fileList, con
|
||||
|
||||
while(line.size() > 0)
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
QString temp1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
|
||||
QString temp2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
|
||||
QString filePath[3];
|
||||
|
||||
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());
|
||||
filename.setCaching(false);
|
||||
fixFilePath(filename, baseDir, rootDir);
|
||||
|
||||
if(filename.exists())
|
||||
if(!filePath[i].contains(QChar(QChar::ReplacementCharacter)))
|
||||
{
|
||||
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
|
||||
if(plsEntry.indexIn(filePath[i]) >= 0)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flag && plsEntry.indexIn(temp2) >= 0)
|
||||
{
|
||||
QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed());
|
||||
filename.setCaching(false);
|
||||
fixFilePath(filename, baseDir, rootDir);
|
||||
QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed());
|
||||
filename.setCaching(false);
|
||||
fixFilePath(filename, baseDir, rootDir);
|
||||
|
||||
if(filename.exists())
|
||||
{
|
||||
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
if(filename.exists())
|
||||
{
|
||||
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user