Skip to content

Commit 1eec3aa

Browse files
committed
ASX,WPL Parsers: Implement no-metadata playlist saving.
1 parent 4de215c commit 1eec3aa

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/playlistparsers/asxparser.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ Song ASXParser::ParseTrack(QXmlStreamReader* reader, const QDir& dir) const {
120120

121121
void ASXParser::Save(const SongList& songs, QIODevice* device, const QDir&,
122122
Playlist::Path path_type) const {
123+
QSettings s;
124+
s.beginGroup(Playlist::kSettingsGroup);
125+
bool writeMetadata = s.value(Playlist::kWriteMetadata, true).toBool();
126+
s.endGroup();
127+
123128
QXmlStreamWriter writer(device);
124129
writer.setAutoFormatting(true);
125130
writer.setAutoFormattingIndent(2);
@@ -129,12 +134,14 @@ void ASXParser::Save(const SongList& songs, QIODevice* device, const QDir&,
129134
writer.writeAttribute("version", "3.0");
130135
for (const Song& song : songs) {
131136
StreamElement entry("entry", &writer);
132-
writer.writeTextElement("title", song.title());
137+
if (!song.title().isEmpty() && writeMetadata) {
138+
writer.writeTextElement("title", song.title());
139+
}
133140
{
134141
StreamElement ref("ref", &writer);
135142
writer.writeAttribute("href", song.url().toString());
136143
}
137-
if (!song.artist().isEmpty()) {
144+
if (!song.artist().isEmpty() && writeMetadata) {
138145
writer.writeTextElement("author", song.artist());
139146
}
140147
}

src/playlistparsers/wplparser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@ void WplParser::ParseSeq(const QDir& dir, QXmlStreamReader* reader,
7979

8080
void WplParser::Save(const SongList& songs, QIODevice* device, const QDir& dir,
8181
Playlist::Path path_type) const {
82+
QSettings s;
83+
s.beginGroup(Playlist::kSettingsGroup);
84+
bool writeMetadata = s.value(Playlist::kWriteMetadata, true).toBool();
85+
s.endGroup();
86+
8287
QXmlStreamWriter writer(device);
8388
writer.setAutoFormatting(true);
8489
writer.setAutoFormattingIndent(2);
8590
writer.writeProcessingInstruction("wpl", "version=\"1.0\"");
8691

8792
StreamElement smil("smil", &writer);
8893

89-
{
94+
if (writeMetadata) {
9095
StreamElement head("head", &writer);
9196
WriteMeta("Generator", "Clementine -- " CLEMENTINE_VERSION_DISPLAY,
9297
&writer);

0 commit comments

Comments
 (0)