summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-03 12:23:45 +0100
committerMax Kellermann <max@duempel.org>2013-12-03 12:23:45 +0100
commit85e587a88232b6d1deb3adbf15d20fa1588b709f (patch)
treeaf56e0de3c5f94dad2c4124a86061f4ccb680b11
parentd91f6dc1b566e78a2f957f855b11b806ba9e3857 (diff)
playlist/pls: use class TagBuilder
-rw-r--r--src/playlist/PlsPlaylistPlugin.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/playlist/PlsPlaylistPlugin.cxx b/src/playlist/PlsPlaylistPlugin.cxx
index d44a34cdf..329bd8bfb 100644
--- a/src/playlist/PlsPlaylistPlugin.cxx
+++ b/src/playlist/PlsPlaylistPlugin.cxx
@@ -23,7 +23,7 @@
#include "MemorySongEnumerator.hxx"
#include "InputStream.hxx"
#include "Song.hxx"
-#include "tag/Tag.hxx"
+#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
@@ -32,6 +32,8 @@
#include <string>
+#include <stdio.h>
+
static constexpr Domain pls_domain("pls");
static void
@@ -75,14 +77,14 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
song = Song::NewRemote(value);
g_free(value);
+ TagBuilder tag;
+
sprintf(key, "Title%u", num_entries);
value = g_key_file_get_string(keyfile, "playlist", key,
&error);
- if(error == nullptr && value){
- if (song->tag == nullptr)
- song->tag = new Tag();
- song->tag->AddItem(TAG_TITLE, value);
- }
+ if (error == nullptr && value != nullptr)
+ tag.AddItem(TAG_TITLE, value);
+
/* Ignore errors? Most likely value not present */
if(error) g_error_free(error);
error = nullptr;
@@ -91,15 +93,14 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
sprintf(key, "Length%u", num_entries);
length = g_key_file_get_integer(keyfile, "playlist", key,
&error);
- if(error == nullptr && length > 0){
- if (song->tag == nullptr)
- song->tag = new Tag();
- song->tag->time = length;
- }
+ if (error == nullptr && length > 0)
+ tag.SetTime(length);
+
/* Ignore errors? Most likely value not present */
if(error) g_error_free(error);
error = nullptr;
+ song->tag = tag.Commit();
songs.emplace_front(song);
num_entries--;
}