Improve ASX/WPL parser. Should be more XML-conform now.
This commit is contained in:
parent
ac53f70488
commit
628bf3de25
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 282
|
||||
#define VER_LAMEXP_BUILD 283
|
||||
#define VER_LAMEXP_SUFFIX Beta-3
|
||||
|
||||
/*
|
||||
|
@ -31,9 +31,13 @@
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
//Un-escape XML characters
|
||||
#define XML_DECODE replace("&", "&").replace("'", "'").replace(" ", " ").replace(""", "\"").replace("<", "<").replace(">", ">")
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -499,19 +503,27 @@ bool FileAnalyzer::parsePlaylist_pls(QFile &data, QStringList &fileList, const Q
|
||||
|
||||
bool FileAnalyzer::parsePlaylist_wpl(QFile &data, QStringList &fileList, const QDir &baseDir, const QDir &rootDir)
|
||||
{
|
||||
QRegExp skipData("<!--(.+)-->", Qt::CaseInsensitive);
|
||||
QRegExp wplEntry("<(media|ref)[^<>]*(src|href)=\"([^\"]+)\"[^<>]*>", Qt::CaseInsensitive);
|
||||
QByteArray line = data.readLine();
|
||||
|
||||
while(line.size() > 0)
|
||||
skipData.setMinimal(true);
|
||||
|
||||
QByteArray buffer = data.readAll();
|
||||
QString line = QString::fromUtf8(buffer.constData(), buffer.size()).simplified();
|
||||
buffer.clear();
|
||||
|
||||
int index = 0;
|
||||
|
||||
while((index = skipData.indexIn(line)) >= 0)
|
||||
{
|
||||
bool flag = false;
|
||||
line.remove(index, skipData.matchedLength());
|
||||
}
|
||||
|
||||
QString temp1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
|
||||
QString temp2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
|
||||
int offset = 0;
|
||||
|
||||
if(!flag && wplEntry.indexIn(temp1) >= 0)
|
||||
while((offset = wplEntry.indexIn(line, offset) + 1) > 0)
|
||||
{
|
||||
QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3)).trimmed());
|
||||
QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3).XML_DECODE.trimmed()));
|
||||
filename.setCaching(false);
|
||||
fixFilePath(filename, baseDir, rootDir);
|
||||
|
||||
@ -520,30 +532,10 @@ bool FileAnalyzer::parsePlaylist_wpl(QFile &data, QStringList &fileList, const Q
|
||||
if(isPlaylist(filename.canonicalFilePath()) == noPlaylist)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!flag && wplEntry.indexIn(temp2) >= 0)
|
||||
{
|
||||
QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3)).trimmed());
|
||||
filename.setCaching(false);
|
||||
fixFilePath(filename, baseDir, rootDir);
|
||||
|
||||
if(filename.exists())
|
||||
{
|
||||
if(isPlaylist(filename.canonicalFilePath()) == noPlaylist)
|
||||
{
|
||||
fileList << filename.canonicalFilePath();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line = data.readLine();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user