Added UTF-16 (LE and BE) support to Playlist and Cue Sheet import.

This commit is contained in:
LoRd_MuldeR 2011-12-13 23:33:21 +01:00
parent c5a28190c4
commit 388f98e90a
6 changed files with 214 additions and 112 deletions

View File

@ -366,7 +366,7 @@
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="110"/>
<location filename="../../src/Dialog_CueImport.cpp" line="199"/>
<location filename="../../src/Dialog_CueImport.cpp" line="207"/>
<source>Failed to load the Cue Sheet file:</source>
<translation type="unfinished"></translation>
</message>
@ -377,156 +377,156 @@
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="111"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<location filename="../../src/Dialog_CueImport.cpp" line="385"/>
<location filename="../../src/Dialog_CueImport.cpp" line="389"/>
<location filename="../../src/Dialog_CueImport.cpp" line="208"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/>
<source>Cue Sheet Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="131"/>
<location filename="../../src/Dialog_CueImport.cpp" line="139"/>
<source>(System Default)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="138"/>
<location filename="../../src/Dialog_CueImport.cpp" line="146"/>
<source>Select ANSI Codepage for Cue Sheet file:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="139"/>
<location filename="../../src/Dialog_CueImport.cpp" line="147"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="140"/>
<location filename="../../src/Dialog_CueImport.cpp" line="148"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="181"/>
<location filename="../../src/Dialog_CueImport.cpp" line="189"/>
<source>An unknown error has occured!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="186"/>
<location filename="../../src/Dialog_CueImport.cpp" line="194"/>
<source>The file could not be opened for reading. Make sure you have the required rights!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="189"/>
<location filename="../../src/Dialog_CueImport.cpp" line="197"/>
<source>The provided file does not look like a valid Cue Sheet disc image file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="192"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<source>Could not find any supported audio track in the Cue Sheet image!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="192"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<source>Note that LameXP can not handle &quot;binary&quot; Cue Sheet images.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="195"/>
<location filename="../../src/Dialog_CueImport.cpp" line="203"/>
<source>The selected Cue Sheet file contains inconsistent information. Take care!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="215"/>
<location filename="../../src/Dialog_CueImport.cpp" line="223"/>
<source>Unknown Artist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="216"/>
<location filename="../../src/Dialog_CueImport.cpp" line="224"/>
<source>Unknown Album</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="231"/>
<location filename="../../src/Dialog_CueImport.cpp" line="235"/>
<location filename="../../src/Dialog_CueImport.cpp" line="239"/>
<location filename="../../src/Dialog_CueImport.cpp" line="243"/>
<source>Choose Output Directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="261"/>
<location filename="../../src/Dialog_CueImport.cpp" line="268"/>
<location filename="../../src/Dialog_CueImport.cpp" line="269"/>
<location filename="../../src/Dialog_CueImport.cpp" line="276"/>
<source>LameXP</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="261"/>
<location filename="../../src/Dialog_CueImport.cpp" line="269"/>
<source>Error: The selected output directory could not be created!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="268"/>
<location filename="../../src/Dialog_CueImport.cpp" line="276"/>
<source>Error: The selected output directory is not writable!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>Low Diskspace Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>There are less than %1 GB of free diskspace available in the selected output directory.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>It is highly recommend to free up more diskspace before proceeding with the import!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="352"/>
<location filename="../../src/Dialog_CueImport.cpp" line="360"/>
<source>Analyzing file(s), please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Analysis Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Warning: The format of some of the input files could not be determined!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Continue Anyway</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Abort</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="380"/>
<location filename="../../src/Dialog_CueImport.cpp" line="388"/>
<source>Splitting file(s), please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="385"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<source>Process was aborted by the user after %1 track(s)!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="389"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/>
<source>An unexpected error has occured while splitting the Cue Sheet!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<location filename="../../src/Dialog_CueImport.cpp" line="401"/>
<source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="394"/>
<location filename="../../src/Dialog_CueImport.cpp" line="402"/>
<source>Cue Sheet Completed</source>
<translation type="unfinished"></translation>
</message>
@ -583,44 +583,44 @@
<context>
<name>CueSheetModel</name>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="209"/>
<location filename="../../src/Model_CueSheet.cpp" line="210"/>
<source>No.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="212"/>
<location filename="../../src/Model_CueSheet.cpp" line="213"/>
<source>File / Track</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="215"/>
<location filename="../../src/Model_CueSheet.cpp" line="216"/>
<source>Index</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="218"/>
<location filename="../../src/Model_CueSheet.cpp" line="219"/>
<source>Duration</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="244"/>
<location filename="../../src/Model_CueSheet.cpp" line="245"/>
<source>File %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="259"/>
<location filename="../../src/Model_CueSheet.cpp" line="260"/>
<source>Track %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="268"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<location filename="../../src/Model_CueSheet.cpp" line="269"/>
<location filename="../../src/Model_CueSheet.cpp" line="277"/>
<source>Unknown Artist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="272"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<location filename="../../src/Model_CueSheet.cpp" line="273"/>
<location filename="../../src/Model_CueSheet.cpp" line="277"/>
<source>Unknown Title</source>
<translation type="unfinished"></translation>
</message>

View File

@ -366,7 +366,7 @@
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="110"/>
<location filename="../../src/Dialog_CueImport.cpp" line="199"/>
<location filename="../../src/Dialog_CueImport.cpp" line="207"/>
<source>Failed to load the Cue Sheet file:</source>
<translation type="unfinished">Ładowanie pliku Cue Sheet zakończone niepowodzeniem:</translation>
</message>
@ -377,156 +377,156 @@
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="111"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<location filename="../../src/Dialog_CueImport.cpp" line="385"/>
<location filename="../../src/Dialog_CueImport.cpp" line="389"/>
<location filename="../../src/Dialog_CueImport.cpp" line="208"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/>
<source>Cue Sheet Error</source>
<translation type="unfinished">Błąd pliku Cue Sheet</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="131"/>
<location filename="../../src/Dialog_CueImport.cpp" line="139"/>
<source>(System Default)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="138"/>
<location filename="../../src/Dialog_CueImport.cpp" line="146"/>
<source>Select ANSI Codepage for Cue Sheet file:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="139"/>
<location filename="../../src/Dialog_CueImport.cpp" line="147"/>
<source>OK</source>
<translation type="unfinished">OK</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="140"/>
<location filename="../../src/Dialog_CueImport.cpp" line="148"/>
<source>Cancel</source>
<translation type="unfinished">Anuluj</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="181"/>
<location filename="../../src/Dialog_CueImport.cpp" line="189"/>
<source>An unknown error has occured!</source>
<translation type="unfinished">Wystąpił nieokreśłony błąd!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="186"/>
<location filename="../../src/Dialog_CueImport.cpp" line="194"/>
<source>The file could not be opened for reading. Make sure you have the required rights!</source>
<translation type="unfinished">Plik nie mógł zostać odczytany. Upewnij się że masz prawo odczytu!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="189"/>
<location filename="../../src/Dialog_CueImport.cpp" line="197"/>
<source>The provided file does not look like a valid Cue Sheet disc image file!</source>
<translation type="unfinished">Dany plik nie wydaje się prawidłowym plikiem obrazu Cue Sheet!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="192"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<source>Could not find any supported audio track in the Cue Sheet image!</source>
<translation type="unfinished">Nie znaleziono wspieranego formatu dźwięku w żadnej ze ścieżek obrazu Cue Sheet!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="192"/>
<location filename="../../src/Dialog_CueImport.cpp" line="200"/>
<source>Note that LameXP can not handle &quot;binary&quot; Cue Sheet images.</source>
<translation type="unfinished">LameXP nie radzi sobie z formatem &quot;binarnym&quot; obrazu Cue Sheet.</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="195"/>
<location filename="../../src/Dialog_CueImport.cpp" line="203"/>
<source>The selected Cue Sheet file contains inconsistent information. Take care!</source>
<translation type="unfinished">Wybrany plik Cue Sheet zawiera niespójne informacje. Prosze zachować ostrożność!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="215"/>
<location filename="../../src/Dialog_CueImport.cpp" line="223"/>
<source>Unknown Artist</source>
<translation type="unfinished">Nieznany Artysta</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="216"/>
<location filename="../../src/Dialog_CueImport.cpp" line="224"/>
<source>Unknown Album</source>
<translation type="unfinished">Nieznany Album</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="231"/>
<location filename="../../src/Dialog_CueImport.cpp" line="235"/>
<location filename="../../src/Dialog_CueImport.cpp" line="239"/>
<location filename="../../src/Dialog_CueImport.cpp" line="243"/>
<source>Choose Output Directory</source>
<translation type="unfinished">Wybierz folder wyjściowy</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="261"/>
<location filename="../../src/Dialog_CueImport.cpp" line="268"/>
<location filename="../../src/Dialog_CueImport.cpp" line="269"/>
<location filename="../../src/Dialog_CueImport.cpp" line="276"/>
<source>LameXP</source>
<translation type="unfinished">LameXP</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="261"/>
<location filename="../../src/Dialog_CueImport.cpp" line="269"/>
<source>Error: The selected output directory could not be created!</source>
<translation type="unfinished">Błąd: Wybrana lokalizacja wyjściowa nie może zostać utworzona!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="268"/>
<location filename="../../src/Dialog_CueImport.cpp" line="276"/>
<source>Error: The selected output directory is not writable!</source>
<translation type="unfinished">Błąd: Nie można zapisać w wybranej lokalizacji wyjściowej!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>Low Diskspace Warning</source>
<translation type="unfinished">Ostrzeżenie o małej ilości miejsca na dysku</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>There are less than %1 GB of free diskspace available in the selected output directory.</source>
<translation type="unfinished">Jest mniej niż %1 GB wolnego miejsca w wybranej lokalizacji wyjściowej.</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="282"/>
<location filename="../../src/Dialog_CueImport.cpp" line="290"/>
<source>It is highly recommend to free up more diskspace before proceeding with the import!</source>
<translation type="unfinished">Jest wysoce zalecane zwolnić miejsce na dysku zanim zaczniesz importować!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="352"/>
<location filename="../../src/Dialog_CueImport.cpp" line="360"/>
<source>Analyzing file(s), please wait...</source>
<translation type="unfinished">Analizowanie pliku/ów, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Analysis Failed</source>
<translation type="unfinished">Analiza zakończona niepowodzeniem</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Warning: The format of some of the input files could not be determined!</source>
<translation type="unfinished">Ostrzeżenie: Nie można rozpoznać formatu kilku plików wejściowych!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Continue Anyway</source>
<translation type="unfinished">Kontynuuj pomimo to</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="357"/>
<location filename="../../src/Dialog_CueImport.cpp" line="365"/>
<source>Abort</source>
<translation type="unfinished">Przerwij</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="380"/>
<location filename="../../src/Dialog_CueImport.cpp" line="388"/>
<source>Splitting file(s), please wait...</source>
<translation type="unfinished">Dzielenie pliku/ów, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="385"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<source>Process was aborted by the user after %1 track(s)!</source>
<translation type="unfinished">Proces został przerwany przez użytkownika po imporcie %1 ścieżek!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="389"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/>
<source>An unexpected error has occured while splitting the Cue Sheet!</source>
<translation type="unfinished">Wystąpił nieoczekiwany błąd podczas podziału pliku Cue Sheet!</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/>
<location filename="../../src/Dialog_CueImport.cpp" line="401"/>
<source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source>
<translation type="unfinished">Zaimportowano %1 ścieżek i opuszczono %2 ścieżek z pliku Cue Sheet.</translation>
</message>
<message>
<location filename="../../src/Dialog_CueImport.cpp" line="394"/>
<location filename="../../src/Dialog_CueImport.cpp" line="402"/>
<source>Cue Sheet Completed</source>
<translation type="unfinished">Stworzono plik Cue Sheet</translation>
</message>
@ -583,44 +583,44 @@
<context>
<name>CueSheetModel</name>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="209"/>
<location filename="../../src/Model_CueSheet.cpp" line="210"/>
<source>No.</source>
<translation type="unfinished">Numer.</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="212"/>
<location filename="../../src/Model_CueSheet.cpp" line="213"/>
<source>File / Track</source>
<translation type="unfinished">Plik/ŚcieżKa</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="215"/>
<location filename="../../src/Model_CueSheet.cpp" line="216"/>
<source>Index</source>
<translation type="unfinished">Indeks</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="218"/>
<location filename="../../src/Model_CueSheet.cpp" line="219"/>
<source>Duration</source>
<translation type="unfinished">Czas trwania</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="244"/>
<location filename="../../src/Model_CueSheet.cpp" line="245"/>
<source>File %1</source>
<translation type="unfinished">Plik %1</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="259"/>
<location filename="../../src/Model_CueSheet.cpp" line="260"/>
<source>Track %1</source>
<translation type="unfinished">Ścieżka %1</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="268"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<location filename="../../src/Model_CueSheet.cpp" line="269"/>
<location filename="../../src/Model_CueSheet.cpp" line="277"/>
<source>Unknown Artist</source>
<translation type="unfinished">Nieznany Artysta</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="272"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<location filename="../../src/Model_CueSheet.cpp" line="273"/>
<location filename="../../src/Model_CueSheet.cpp" line="277"/>
<source>Unknown Title</source>
<translation type="unfinished">Nieznany Tytuł</translation>
</message>

View File

@ -29,8 +29,8 @@
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 8
#define VER_LAMEXP_BUILD 807
#define VER_LAMEXP_PATCH 9
#define VER_LAMEXP_BUILD 810
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -120,12 +120,20 @@ int CueImportDialog::exec(void)
QFile cueFile(cueFileInfo.canonicalFilePath());
cueFile.open(QIODevice::ReadOnly);
QByteArray bomCheck = cueFile.isOpen() ? cueFile.peek(128) : QByteArray();
QByteArray bomCheck = cueFile.isOpen() ? cueFile.peek(16) : QByteArray();
if((!bomCheck.isEmpty()) && bomCheck.contains("\xef\xbb\xbf"))
if((!bomCheck.isEmpty()) && bomCheck.startsWith("\xef\xbb\xbf"))
{
codec = QTextCodec::codecForName("UTF-8");
}
else if((!bomCheck.isEmpty()) && bomCheck.startsWith("\xff\xfe"))
{
codec = QTextCodec::codecForName("UTF-16LE");
}
else if((!bomCheck.isEmpty()) && bomCheck.startsWith("\xfe\xff"))
{
codec = QTextCodec::codecForName("UTF-16BE");
}
else
{
const QString systemDefault = tr("(System Default)");

View File

@ -29,6 +29,7 @@
#include <QFont>
#include <QTime>
#include <QTextCodec>
#include <QTextStream>
#include <float.h>
#include <limits>
@ -549,7 +550,7 @@ int CueSheetModel::loadCueSheet(const QString &cueFileName, QCoreApplication *ap
int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplication *application, const QTextCodec *codec)
{
cueFile.seek(0);
cueFile.reset();
qDebug("\n[Cue Sheet Import]");
bool bForceLatin1 = false;
@ -566,11 +567,17 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
QByteArray testData = cueFile.peek(1048576);
if((!testData.isEmpty()) && codec->toUnicode(testData.constData(), testData.size()).contains(replacementSymbol))
{
qWarning("Decoding error using local codepage. Enforcing Latin-1.");
qWarning("Decoding error using selected codepage (%s). Enforcing Latin-1.", codec->name().constData());
bForceLatin1 = true;
}
testData.clear();
//Init text stream
QTextStream cueStream(&cueFile);
cueStream.setAutoDetectUnicode(false);
cueStream.setCodec(bForceLatin1 ? "latin1" : codec->name());
cueStream.seek(0i64);
//Create regular expressions
QRegExp rxFile("^FILE\\s+(\"[^\"]+\"|\\S+)\\s+(\\w+)$", Qt::CaseInsensitive);
QRegExp rxTrack("^TRACK\\s+(\\d+)\\s(\\w+)$", Qt::CaseInsensitive);
@ -600,14 +607,13 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(lines < 128) Sleep(10);
}
QByteArray lineData = cueFile.readLine();
if(lineData.size() <= 0)
if(cueStream.atEnd())
{
qDebug("End of Cue Sheet file.");
break;
}
QString line = (bForceLatin1 ? QString::fromLatin1(lineData.constData(), lineData.size()) : codec->toUnicode(lineData.constData(), lineData.size())).trimmed();
QString line = cueStream.readLine().trimmed();
/* --- FILE --- */
if(rxFile.indexIn(line) >= 0)

View File

@ -86,6 +86,13 @@ bool PlaylistImporter::importPlaylist(QStringList &fileList, const QString &play
return false;
}
//Skip very large files (parsing could take very long)
if(data.size() >= 10485760i64)
{
qWarning("File is very big. Probably not a Playlist. Rejecting...");
return false;
}
//Parse playlist depending on type
switch(playlistType)
{
@ -132,14 +139,16 @@ 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);
const QTextCodec *codec = QTextCodec::codecForName("System");
const bool preferUTF8 = data.fileName().endsWith(".m3u8", Qt::CaseInsensitive);
bool foundAtLeastOneFile = false;
data.reset();
while(line.size() > 0)
while(!data.atEnd())
{
QString filePath[3];
QByteArray line = data.readLine();
if(preferUTF8)
{
@ -156,24 +165,61 @@ bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, con
for(size_t i = 0; i < 3; i++)
{
if(!(filePath[i].startsWith("#") || filePath[i].contains(QChar(QChar::ReplacementCharacter))))
if(!(filePath[i].isEmpty() || filePath[i].startsWith("#") || filePath[i].contains(QChar(QChar::ReplacementCharacter))))
{
QFileInfo filename(filePath[i]);
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists())
if(filename.exists() && filename.isFile())
{
qDebug("Found: \"%s\"", filePath[i].toUtf8().constData());
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{
fileList << filename.canonicalFilePath();
}
foundAtLeastOneFile = true;
break;
}
}
}
}
line = data.readLine();
//If we did not find any files yet, try UTF-16 now
if(!foundAtLeastOneFile)
{
const char* codecs[2] = {"UTF-16LE", "UTF-16BE"};
for(size_t i = 0; i < 2; i++)
{
QTextStream stream(&data);
stream.setAutoDetectUnicode(false);
stream.setCodec(codecs[i]);
stream.seek(0i64);
while(!stream.atEnd())
{
QString filePath = stream.readLine().trimmed();
if(!(filePath.isEmpty() || filePath.startsWith("#") || filePath.contains(QChar(QChar::ReplacementCharacter))))
{
QFileInfo filename(filePath);
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists() && filename.isFile())
{
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{
fileList << filename.canonicalFilePath();
}
foundAtLeastOneFile = true;
}
}
}
if(foundAtLeastOneFile) break;
}
}
return true;
@ -183,11 +229,14 @@ bool PlaylistImporter::parsePlaylist_pls(QFile &data, QStringList &fileList, con
{
QRegExp plsEntry("File(\\d+)=(.+)", Qt::CaseInsensitive);
const QTextCodec *codec = QTextCodec::codecForName("System");
QByteArray line = data.readLine();
while(line.size() > 0)
bool foundAtLeastOneFile = false;
data.reset();
while(!data.atEnd())
{
QString filePath[3];
QByteArray line = data.readLine();
filePath[0] = QString(QDir::fromNativeSeparators(codec->toUnicode(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
@ -203,19 +252,58 @@ bool PlaylistImporter::parsePlaylist_pls(QFile &data, QStringList &fileList, con
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists())
if(filename.exists() && filename.isFile())
{
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{
fileList << filename.canonicalFilePath();
}
foundAtLeastOneFile = true;
break;
}
}
}
}
}
line = data.readLine();
//If we did not find any files yet, try UTF-16 now
if(!foundAtLeastOneFile)
{
const char* codecs[2] = {"UTF-16LE", "UTF-16BE"};
for(size_t i = 0; i < 2; i++)
{
QTextStream stream(&data);
stream.setAutoDetectUnicode(false);
stream.setCodec(codecs[i]);
stream.seek(0i64);
while(!stream.atEnd())
{
QString filePath = stream.readLine().trimmed();
if(!filePath.contains(QChar(QChar::ReplacementCharacter)))
{
if(plsEntry.indexIn(filePath) >= 0)
{
QFileInfo filename(QDir::fromNativeSeparators(plsEntry.cap(2)).trimmed());
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists() && filename.isFile())
{
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{
fileList << filename.canonicalFilePath();
}
foundAtLeastOneFile = true;
}
}
}
}
if(foundAtLeastOneFile) break;
}
}
return true;
@ -247,7 +335,7 @@ bool PlaylistImporter::parsePlaylist_wpl(QFile &data, QStringList &fileList, con
filename.setCaching(false);
fixFilePath(filename, baseDir, rootDir);
if(filename.exists())
if(filename.exists() && filename.isFile())
{
if(isPlaylist(filename.canonicalFilePath()) == notPlaylist)
{