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(); for (const Song& song : songs) { if (song.url().isEmpty()) { continue; } if (writeMetadata) { QString meta = QString("#EXTINF:%1,%2 - %3\n") .arg(song.length_nanosec() / kNsecPerSec) .arg(song.artist()) .arg(song.title()); device->write(meta.toUtf8()); } device->write(URLOrFilename(song.url(), dir, path_type).toUtf8()); device->write("\n"); } }
void WplParser::Save(const SongList& songs, QIODevice* device, const QDir& dir, Playlist::Path path_type) const { QXmlStreamWriter writer(device); writer.setAutoFormatting(true); writer.setAutoFormattingIndent(2); writer.writeProcessingInstruction("wpl", "version=\"1.0\""); StreamElement smil("smil", &writer); { StreamElement head("head", &writer); WriteMeta("Generator", "Clementine -- " CLEMENTINE_VERSION_DISPLAY, &writer); WriteMeta("ItemCount", QString::number(songs.count()), &writer); } { StreamElement body("body", &writer); { StreamElement seq("seq", &writer); for (const Song& song : songs) { writer.writeStartElement("media"); writer.writeAttribute("src", URLOrFilename(song.url(), dir, path_type)); writer.writeEndElement(); } } } }
void AsxIniParser::Save(const SongList& songs, QIODevice* device, const QDir& dir, Playlist::Path path_type) const { QTextStream s(device); s << "[Reference]" << endl; int n = 1; for (const Song& song : songs) { s << "Ref" << n << "=" << URLOrFilename(song.url(), dir, path_type) << endl; ++n; } }