annotate Plugins/Container/xspf/xspf.c @ 1584:2229b67f1b89 trunk

[svn] - xspf stores all meta data in tuples now. - at load time, tuple for each entry in a playlist can be constructed from xspf. it means no read access to meta data in each data file is needed.
author yaz
date Sat, 19 Aug 2006 12:28:56 -0700
parents d60e3dbe1a48
children c4b78bc50412
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
1 /*
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
2 * Audacious: A cross-platform multimedia player
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
5 *
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
9 * (at your option) any later version.
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
10 *
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
15 *
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
19 */
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
20
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
21 #include <glib.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
22 #include <string.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
23 #include <glib.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
24 #include <glib/gprintf.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
25 #include <stdlib.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
26 #include <string.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
27 #include <time.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
28
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
29 #include <unistd.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
30 #include <sys/types.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
31 #include <sys/stat.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
32 #include <sys/errno.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
33
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
34 #include "audacious/main.h"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
35 #include "audacious/util.h"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
36 #include "audacious/playlist.h"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
37 #include "audacious/playlist_container.h"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
38 #include "audacious/plugin.h"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
39
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
40 #include <libxml/tree.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
41 #include <libxml/parser.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
42 #include <libxml/xmlreader.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
43 #include <libxml/xpath.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
44 #include <libxml/xpathInternals.h>
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
45
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
46 static void
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
47 add_file(xmlNode *track, const gchar *filename, gint pos)
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
48 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
49 xmlNode *nptr;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
50 TitleInput *tuple;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
51 gchar *locale_uri = NULL;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
52
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
53 XMMS_NEW_TITLEINPUT(tuple);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
54
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
55 // creator, album, title, duration, trackNum, annotation, image,
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
56 for(nptr = track->children; nptr != NULL; nptr = nptr->next){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
57 if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "location")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
58 xmlChar *str = xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
59 locale_uri = g_locale_from_utf8(str,-1,NULL,NULL,NULL);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
60 if(!locale_uri){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
61 /* try ISO-8859-1 for last resort */
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
62 locale_uri = g_convert(str, -1, "ISO-8859-1", "UTF-8", NULL, NULL, NULL);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
63 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
64 xmlFree(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
65 if(locale_uri){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
66 tuple->file_name = g_path_get_basename(locale_uri);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
67 tuple->file_path = g_strdup(locale_uri);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
68 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
69 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
70 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "creator")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
71 tuple->performer = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
72 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
73 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "album")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
74 tuple->album_name = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
75 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
76 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "title")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
77 tuple->track_name = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
78 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
79 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "duration")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
80 xmlChar *str = xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
81 tuple->length = atol(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
82 xmlFree(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
83 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
84 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "trackNum")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
85 xmlChar *str = xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
86 tuple->track_number = atol(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
87 xmlFree(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
88 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
89
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
90 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
91 // additional metadata
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
92 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
93 // year, date, genre, comment, file_ext, file_path, formatter
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
94 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
95 else if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "meta")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
96 xmlChar *rel = NULL;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
97
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
98 rel = xmlGetProp(nptr, "rel");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
99
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
100 if(!strcmp(rel, "year")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
101 xmlChar *cont = xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
102 tuple->year = atol(cont);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
103 xmlFree(cont);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
104 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
105 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
106 else if(!strcmp(rel, "date")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
107 tuple->date = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
108 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
109 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
110 else if(!strcmp(rel, "genre")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
111 tuple->genre = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
112 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
113 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
114 else if(!strcmp(rel, "comment")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
115 tuple->comment = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
116 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
117 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
118 else if(!strcmp(rel, "file_ext")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
119 tuple->file_ext = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
120 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
121 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
122 else if(!strcmp(rel, "file_path")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
123 tuple->file_path = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
124 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
125 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
126 else if(!strcmp(rel, "formatter")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
127 tuple->formatter = (gchar *)xmlNodeGetContent(nptr);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
128 continue;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
129 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
130 xmlFree(rel);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
131 rel = NULL;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
132 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
133
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
134 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
135 // add file to playlist
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
136 playlist_load_ins_file_tuple(locale_uri, filename, pos, tuple);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
137 pos++;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
138 if(locale_uri) {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
139 g_free(locale_uri);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
140 locale_uri = NULL;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
141 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
142 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
143
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
144 static void
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
145 find_track(xmlNode *tracklist, const gchar *filename, gint pos)
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
146 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
147 xmlNode *nptr;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
148 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
149 if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "track")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
150 add_file(nptr, filename, pos);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
151 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
152 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
153 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
154
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
155 static void
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
156 playlist_load_xspf(const gchar * filename, gint pos)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
157 {
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
158 xmlDocPtr doc;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
159 xmlNode *nptr, *nptr2;
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
160
1570
4023a295db39 [svn] - wma: use posix_memalign() instead of memalign() in some more spots
nenolod
parents: 1569
diff changeset
161 g_return_if_fail(filename != NULL);
4023a295db39 [svn] - wma: use posix_memalign() instead of memalign() in some more spots
nenolod
parents: 1569
diff changeset
162
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
163 doc = xmlParseFile(filename);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
164 if (doc == NULL)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
165 return;
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
166
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
167 // find trackList
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
168 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
169 if(nptr->type == XML_ELEMENT_NODE && !strcmp(nptr->name, "playlist")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
170 for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
171 if(nptr2->type == XML_ELEMENT_NODE && !strcmp(nptr2->name, "trackList")){
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
172 find_track(nptr2, filename, pos);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
173 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
174 }
1573
56e1da886c9f [svn] - remove unnecessary and crappy code
nenolod
parents: 1572
diff changeset
175
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
176 }
1574
a8a2ee855c1c [svn] - unbork
nenolod
parents: 1573
diff changeset
177 }
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
178
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
179 xmlFreeDoc(doc);
1571
0b69bc0eb2d2 [svn] - if uri == NULL, then continue looking for URIs in the XSPF playlist
nenolod
parents: 1570
diff changeset
180
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
181 }
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
182
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
183
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
184 #define XSPF_ROOT_NODE_NAME "playlist"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
185 #define XSPF_XMLNS "http://xspf.org/ns/0/"
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
186
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
187 static void
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
188 playlist_save_xspf(const gchar *filename, gint pos)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
189 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
190 xmlDocPtr doc;
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
191 xmlNodePtr rootnode, tmp, tracklist;
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
192 GList *node;
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
193
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
194 doc = xmlNewDoc("1.0");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
195
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
196 rootnode = xmlNewNode(NULL, XSPF_ROOT_NODE_NAME);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
197 xmlSetProp(rootnode, "xmlns", XSPF_XMLNS);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
198 xmlSetProp(rootnode, "version", "1");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
199 xmlDocSetRootElement(doc, rootnode);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
200
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
201 tmp = xmlNewNode(NULL, "creator");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
202 xmlAddChild(tmp, xmlNewText(PACKAGE "-" VERSION));
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
203 xmlAddChild(rootnode, tmp);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
204
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
205 tracklist = xmlNewNode(NULL, "trackList");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
206 xmlAddChild(rootnode, tracklist);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
207
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
208 for (node = playlist_get(); node != NULL; node = g_list_next(node))
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
209 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
210 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
211 xmlNodePtr track, location;
1575
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
212 gchar *utf_filename = NULL;
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
213
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
214 track = xmlNewNode(NULL, "track");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
215 location = xmlNewNode(NULL, "location");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
216
1579
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
217 /* try locale encoding first */
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
218 utf_filename = g_locale_to_utf8(entry->filename, -1, NULL, NULL, NULL);
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
219
1579
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
220 if (!utf_filename) {
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
221 /* if above fails, try to guess */
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
222 utf_filename = str_to_utf8(entry->filename);
d60e3dbe1a48 [svn] - better handling for file name which can't be represented correctly in current locale encoding.
yaz
parents: 1575
diff changeset
223 }
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
224
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
225 if(!g_utf8_validate(utf_filename, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
226 continue;
1575
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
227 xmlAddChild(location, xmlNewText(utf_filename));
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
228 xmlAddChild(track, location);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
229 xmlAddChild(tracklist, track);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
230
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
231 /* do we have a tuple? */
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
232 if (entry->tuple != NULL)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
233 {
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
234 if (entry->tuple->performer != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
235 g_utf8_validate(entry->tuple->performer, -1, NULL))
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
236 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
237 tmp = xmlNewNode(NULL, "creator");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
238 xmlAddChild(tmp, xmlNewText(entry->tuple->performer));
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
239 xmlAddChild(track, tmp);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
240 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
241
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
242 if (entry->tuple->album_name != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
243 g_utf8_validate(entry->tuple->album_name, -1, NULL))
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
244 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
245 tmp = xmlNewNode(NULL, "album");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
246 xmlAddChild(tmp, xmlNewText(entry->tuple->album_name));
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
247 xmlAddChild(track, tmp);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
248 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
249
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
250 if (entry->tuple->track_name != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
251 g_utf8_validate(entry->tuple->track_name, -1, NULL))
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
252 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
253 tmp = xmlNewNode(NULL, "title");
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
254 xmlAddChild(tmp, xmlNewText(entry->tuple->track_name));
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
255 xmlAddChild(track, tmp);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
256 }
1584
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
257
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
258 if (entry->tuple->length != 0)
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
259 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
260 gchar *str;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
261 str = g_malloc(128); // XXX fix me.
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
262 tmp = xmlNewNode(NULL, "duration");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
263 sprintf(str, "%d", entry->tuple->length);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
264 xmlAddChild(tmp, xmlNewText(str));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
265 g_free(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
266 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
267 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
268
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
269 if (entry->tuple->track_number != 0)
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
270 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
271 gchar *str;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
272 str = g_malloc(128); // XXX fix me.
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
273 tmp = xmlNewNode(NULL, "trackNum");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
274 sprintf(str, "%d", entry->tuple->track_number);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
275 xmlAddChild(tmp, xmlNewText(str));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
276 g_free(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
277 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
278 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
279
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
280 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
281 // additional metadata
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
282 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
283 // year, date, genre, comment, file_ext, file_path, formatter
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
284 //
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
285 if (entry->tuple->year != 0)
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
286 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
287 gchar *str;
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
288 str = g_malloc(128); // XXX fix me.
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
289 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
290 xmlSetProp(tmp, "rel", "year");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
291 sprintf(str, "%d", entry->tuple->year);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
292 xmlAddChild(tmp, xmlNewText(str));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
293 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
294 g_free(str);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
295 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
296
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
297 if (entry->tuple->date != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
298 g_utf8_validate(entry->tuple->date, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
299 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
300 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
301 xmlSetProp(tmp, "rel", "date");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
302 xmlAddChild(tmp, xmlNewText(entry->tuple->date));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
303 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
304 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
305
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
306 if (entry->tuple->genre != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
307 g_utf8_validate(entry->tuple->genre, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
308 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
309 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
310 xmlSetProp(tmp, "rel", "genre");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
311 xmlAddChild(tmp, xmlNewText(entry->tuple->genre));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
312 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
313 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
314
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
315 if (entry->tuple->comment != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
316 g_utf8_validate(entry->tuple->comment, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
317 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
318 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
319 xmlSetProp(tmp, "rel", "comment");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
320 xmlAddChild(tmp, xmlNewText(entry->tuple->comment));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
321 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
322 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
323
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
324 if (entry->tuple->file_ext != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
325 g_utf8_validate(entry->tuple->file_ext, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
326 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
327 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
328 xmlSetProp(tmp, "rel", "file_ext");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
329 xmlAddChild(tmp, xmlNewText(entry->tuple->file_ext));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
330 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
331 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
332
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
333 if (entry->tuple->file_path != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
334 g_utf8_validate(entry->tuple->file_path, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
335 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
336 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
337 xmlSetProp(tmp, "rel", "file_path");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
338 xmlAddChild(tmp, xmlNewText(entry->tuple->file_path));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
339 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
340 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
341
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
342 if (entry->tuple->formatter != NULL &&
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
343 g_utf8_validate(entry->tuple->formatter, -1, NULL))
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
344 {
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
345 tmp = xmlNewNode(NULL, "meta");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
346 xmlSetProp(tmp, "rel", "formatter");
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
347 xmlAddChild(tmp, xmlNewText(entry->tuple->formatter));
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
348 xmlAddChild(track, tmp);
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
349 }
2229b67f1b89 [svn] - xspf stores all meta data in tuples now.
yaz
parents: 1579
diff changeset
350
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
351 }
1575
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
352 if(utf_filename) {
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
353 g_free(utf_filename);
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
354 utf_filename = NULL;
e6fce20309f9 [svn] xspf.c needs round trip encoding conversion between locale encoding and utf8.
yaz
parents: 1574
diff changeset
355 }
1568
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
356 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
357
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
358 xmlSaveFile(filename, doc);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
359 xmlFreeDoc(doc);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
360 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
361
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
362 PlaylistContainer plc_xspf = {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
363 .name = "XSPF Playlist Format",
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
364 .ext = "xspf",
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
365 .plc_read = playlist_load_xspf,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
366 .plc_write = playlist_save_xspf,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
367 };
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
368
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
369 static void init(void)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
370 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
371 playlist_container_register(&plc_xspf);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
372 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
373
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
374 static void cleanup(void)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
375 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
376 playlist_container_unregister(&plc_xspf);
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
377 }
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
378
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
379 LowlevelPlugin llp_xspf = {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
380 NULL,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
381 NULL,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
382 "XSPF Playlist Format",
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
383 init,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
384 cleanup,
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
385 };
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
386
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
387 LowlevelPlugin *get_lplugin_info(void)
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
388 {
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
389 return &llp_xspf;
0a927f814a12 [svn] - experimental XSPF support
nenolod
parents:
diff changeset
390 }