Skip to content

Commit

Permalink
ASX Parser: Implement no-metadata playlist saving.
Browse files Browse the repository at this point in the history
  • Loading branch information
smithjd15 committed Mar 17, 2022
1 parent 7bc54f7 commit c69a64d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/playlistparsers/asxparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ Song ASXParser::ParseTrack(QXmlStreamReader* reader, const QDir& dir) const {

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.setAutoFormatting(true);
writer.setAutoFormattingIndent(2);
Expand All @@ -129,12 +134,14 @@ void ASXParser::Save(const SongList& songs, QIODevice* device, const QDir&,
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());
}
}
Expand Down

0 comments on commit c69a64d

Please sign in to comment.