Merge 351f0c2d75
into 2f3464403b
This commit is contained in:
commit
804548ec04
|
@ -120,26 +120,32 @@ return_song:
|
|||
|
||||
void ASXParser::Save(const SongList& songs, QIODevice* device, const QDir&,
|
||||
Playlist::Path path_type) const {
|
||||
QSettings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
bool writeMetadata = s.value(Playlist::kWriteMetadata, true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
QXmlStreamWriter writer(device);
|
||||
writer.writeStartElement("asx");
|
||||
writer.writeAttribute("version", "3.0");
|
||||
writer.setAutoFormatting(true);
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeStartDocument();
|
||||
{
|
||||
StreamElement asx("asx", &writer);
|
||||
writer.writeAttribute("version", "3.0");
|
||||
for (const Song& song : songs) {
|
||||
StreamElement entry("entry", &writer);
|
||||
writer.writeTextElement("title", song.title());
|
||||
if (!song.title().isEmpty() && writeMetadata) {
|
||||
writer.writeTextElement("title", song.title());
|
||||
}
|
||||
{
|
||||
StreamElement ref("ref", &writer);
|
||||
writer.writeAttribute("href", song.url().toString());
|
||||
}
|
||||
if (!song.artist().isEmpty()) {
|
||||
if (!song.artist().isEmpty() && writeMetadata) {
|
||||
writer.writeTextElement("author", song.artist());
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.writeEndDocument();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
bool ASXParser::TryMagic(const QByteArray& data) const {
|
||||
|
|
|
@ -103,13 +103,15 @@ bool M3UParser::ParseMetadata(const QString& line,
|
|||
|
||||
void M3UParser::Save(const SongList& songs, QIODevice* device, const QDir& dir,
|
||||
Playlist::Path path_type) const {
|
||||
device->write("#EXTM3U\n");
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
bool writeMetadata = s.value(Playlist::kWriteMetadata, true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
if (writeMetadata) {
|
||||
device->write("#EXTM3U\n");
|
||||
}
|
||||
|
||||
for (const Song& song : songs) {
|
||||
if (song.url().isEmpty()) {
|
||||
continue;
|
||||
|
|
|
@ -66,17 +66,26 @@ void PLSParser::Save(const SongList& songs, QIODevice* device, const QDir& dir,
|
|||
Playlist::Path path_type) const {
|
||||
QTextStream s(device);
|
||||
s << "[playlist]" << endl;
|
||||
s << "Version=2" << endl;
|
||||
s << "NumberOfEntries=" << songs.count() << endl;
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup(Playlist::kSettingsGroup);
|
||||
bool writeMetadata = settings.value(Playlist::kWriteMetadata, true).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
int n = 1;
|
||||
for (const Song& song : songs) {
|
||||
s << "File" << n << "=" << URLOrFilename(song.url(), dir, path_type)
|
||||
<< endl;
|
||||
s << "Title" << n << "=" << song.title() << endl;
|
||||
s << "Length" << n << "=" << song.length_nanosec() / kNsecPerSec << endl;
|
||||
if (writeMetadata) {
|
||||
s << "Title" << n << "=" << song.title() << endl;
|
||||
s << "Length" << n << "=" << song.length_nanosec() / kNsecPerSec << endl;
|
||||
}
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
s << "NumberOfEntries=" << songs.count() << endl;
|
||||
s << "Version=2" << endl;
|
||||
}
|
||||
|
||||
bool PLSParser::TryMagic(const QByteArray& data) const {
|
||||
|
|
|
@ -79,14 +79,19 @@ void WplParser::ParseSeq(const QDir& dir, QXmlStreamReader* reader,
|
|||
|
||||
void WplParser::Save(const SongList& songs, QIODevice* device, const QDir& dir,
|
||||
Playlist::Path path_type) const {
|
||||
QSettings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
bool writeMetadata = s.value(Playlist::kWriteMetadata, true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
QXmlStreamWriter writer(device);
|
||||
writer.writeProcessingInstruction("wpl", "version=\"1.0\"");
|
||||
writer.setAutoFormatting(true);
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeProcessingInstruction("wpl", "version=\"1.0\"");
|
||||
|
||||
StreamElement smil("smil", &writer);
|
||||
|
||||
{
|
||||
if (writeMetadata) {
|
||||
StreamElement head("head", &writer);
|
||||
WriteMeta("Generator", "Clementine -- " CLEMENTINE_VERSION_DISPLAY,
|
||||
&writer);
|
||||
|
|
Loading…
Reference in New Issue