summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrvi <crvisqr@gmail.com>2021-04-20 17:57:56 +0530
committerBastien Nocera <hadess@hadess.net>2021-04-23 11:57:57 +0000
commitad41906dca8db0480ba7a3c9833478622ecb0b89 (patch)
tree69160115023b624285fc117e530016e2d678a6bc
parent8bcef58ee3d18f6daba087152b091f481c524450 (diff)
downloadtotem-pl-parser-ad41906dca8db0480ba7a3c9833478622ecb0b89.tar.gz
xspf: Save playlist title to xspf file
Closes: #31
-rw-r--r--plparse/totem-pl-parser-xspf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/plparse/totem-pl-parser-xspf.c b/plparse/totem-pl-parser-xspf.c
index 1a50316..e34420b 100644
--- a/plparse/totem-pl-parser-xspf.c
+++ b/plparse/totem-pl-parser-xspf.c
@@ -106,15 +106,23 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
TotemPlPlaylistIter iter;
GFileOutputStream *stream;
char *buf;
+ GString *str;
gboolean valid, success;
stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, cancellable, error);
if (stream == NULL)
return FALSE;
- buf = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
- " <trackList>\n");
+ str = g_string_new ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n");
+
+ if (title != NULL && title[0] != '\0') {
+ g_string_append_printf (str, "<title>%s</title>\n", title);
+ }
+
+ str = g_string_append (str, " <trackList>\n");
+ buf = g_string_free (str, FALSE);
+
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)