Skip to content

Commit

Permalink
ASX,WPL Parsers: Implement no-metadata playlist saving.
Browse files Browse the repository at this point in the history
  • Loading branch information
smithjd15 committed Mar 16, 2022
1 parent 4de215c commit 1eec3aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 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
7 changes: 6 additions & 1 deletion src/playlistparsers/wplparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.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);
Expand Down

0 comments on commit 1eec3aa

Please sign in to comment.