[totem-pl-parser] xspf: Save playlist title to xspf file
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] xspf: Save playlist title to xspf file
- Date: Fri, 23 Apr 2021 12:02:56 +0000 (UTC)
commit ad41906dca8db0480ba7a3c9833478622ecb0b89
Author: crvi <crvisqr gmail com>
Date: Tue Apr 20 17:57:56 2021 +0530
xspf: Save playlist title to xspf file
Closes: #31
plparse/totem-pl-parser-xspf.c | 14 +++++++++++---
1 file 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]