Mercurial > audlegacy-plugins
annotate src/xspf/xspf.c @ 884:4fd90f2d1832 trunk
[svn] improve support for static playlist:
- make use of Playlist.attribute.
- now xspf plugin is capable of embedding static playlist marker. user can specify at "Save Playlist" dialog.
- all meaningful mtime value will be preserved even if a playlist file is handled as static playlist.
author | yaz |
---|---|
date | Wed, 21 Mar 2007 02:32:49 -0700 |
parents | f46c9abe09d4 |
children | 502222ed5dd4 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 * Audacious: A cross-platform multimedia player |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 * (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 #include <config.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 #include <glib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include <time.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include <unistd.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 #include <sys/types.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 #include <sys/stat.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 #include <sys/errno.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #include "audacious/main.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 #include "audacious/util.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 #include "audacious/playlist.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 #include "audacious/playlist_container.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 #include "audacious/plugin.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 #include <libxml/tree.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 #include <libxml/parser.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 #include <libxml/xmlreader.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 #include <libxml/xpath.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 #include <libxml/xpathInternals.h> |
641 | 44 #include <libxml/uri.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 |
641 | 46 #define XSPF_ROOT_NODE_NAME "playlist" |
47 #define XSPF_XMLNS "http://xspf.org/ns/0/" | |
47 | 48 |
49 #define TMP_BUF_LEN 128 | |
50 | |
641 | 51 gchar *base = NULL; |
52 | |
652
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
53 // this function is taken from libxml2-2.6.27. |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
54 static xmlChar * |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
55 audPathToURI(const xmlChar *path) |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
56 { |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
57 xmlURIPtr uri; |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
58 xmlURI temp; |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
59 xmlChar *ret, *cal; |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
60 |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
61 if (path == NULL) |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
62 return(NULL); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
63 |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
64 if ((uri = xmlParseURI((const char *) path)) != NULL) { |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
65 xmlFreeURI(uri); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
66 return xmlStrdup(path); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
67 } |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
68 cal = xmlCanonicPath(path); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
69 if (cal == NULL) |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
70 return(NULL); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
71 memset(&temp, 0, sizeof(temp)); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
72 temp.path = (char *) cal; |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
73 ret = xmlSaveUri(&temp); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
74 xmlFree(cal); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
75 return(ret); |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
76 } |
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
77 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
79 add_file(xmlNode *track, const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 xmlNode *nptr; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 TitleInput *tuple; |
641 | 83 gchar *location = NULL; |
361
f201074bf69a
[svn] - update playlist code. M3U was simple and did not require anything special.
nenolod
parents:
95
diff
changeset
|
84 Playlist *playlist = playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
85 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 tuple = bmp_title_input_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 |
884 | 88 tuple->length = -1; |
657 | 89 tuple->mtime = -1; // mark as uninitialized. |
641 | 90 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
91 // creator, album, title, duration, trackNum, annotation, image, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 for(nptr = track->children; nptr != NULL; nptr = nptr->next){ |
641 | 93 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"location")){ |
94 gchar *str = (gchar *)xmlNodeGetContent(nptr); | |
657 | 95 gchar *tmp; |
96 | |
97 if( strncmp(str, "http://", 7) && strncmp(str, "https://", 8) && | |
98 strncmp(str, "mms://", 6) ) { /* not a streaming */ | |
99 tmp = (gchar *)xmlURIUnescapeString(str, -1, NULL); | |
100 } | |
101 else { /* streaming */ | |
102 tmp = g_strdup(str); | |
103 } | |
641 | 104 |
105 if(strstr(tmp, "file://")){ | |
106 location = g_strdup_printf("%s%s", base ? base : "", tmp+7); | |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
107 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
108 else { |
641 | 109 location = g_strdup_printf("%s%s", base ? base : "", tmp); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
110 } |
641 | 111 xmlFree(str); g_free(tmp); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
112 } |
641 | 113 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"title")){ |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
114 tuple->track_name = (gchar *)xmlNodeGetContent(nptr); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 } |
641 | 116 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"creator")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 tuple->performer = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 } |
641 | 119 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"annotation")){ |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
120 tuple->comment = (gchar *)xmlNodeGetContent(nptr); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
121 } |
641 | 122 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"album")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 tuple->album_name = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 } |
641 | 125 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"trackNum")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 xmlChar *str = xmlNodeGetContent(nptr); |
641 | 127 tuple->track_number = atol((char *)str); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 xmlFree(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
129 } |
641 | 130 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"duration")){ |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
131 xmlChar *str = xmlNodeGetContent(nptr); |
641 | 132 tuple->length = atol((char *)str); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
133 xmlFree(str); |
47 | 134 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
135 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
136 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 // additional metadata |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 // |
641 | 139 // year, date, genre, formatter, mtime |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
140 // |
641 | 141 else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"meta")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 xmlChar *rel = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 |
641 | 144 rel = xmlGetProp(nptr, (xmlChar *)"rel"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 |
641 | 146 if(!xmlStrcmp(rel, (xmlChar *)"year")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 xmlChar *cont = xmlNodeGetContent(nptr); |
641 | 148 tuple->year = atol((char *)cont); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 xmlFree(cont); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 } |
641 | 152 else if(!xmlStrcmp(rel, (xmlChar *)"date")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 tuple->date = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 } |
641 | 156 else if(!xmlStrcmp(rel, (xmlChar *)"genre")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 tuple->genre = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
158 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 } |
641 | 160 else if(!xmlStrcmp(rel, (xmlChar *)"formatter")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 tuple->formatter = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 } |
641 | 164 else if(!xmlStrcmp(rel, (xmlChar *)"mtime")){ |
47 | 165 xmlChar *str = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
166 str = xmlNodeGetContent(nptr); |
641 | 167 tuple->mtime = (time_t)atoll((char *)str); |
47 | 168 xmlFree(str); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
169 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
170 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 xmlFree(rel); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 rel = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
173 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 } |
87
fabe64e89949
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
47
diff
changeset
|
176 |
641 | 177 if(location){ |
178 tuple->file_name = g_path_get_basename(location); | |
179 tuple->file_path = g_path_get_dirname(location); | |
180 tuple->file_ext = g_strdup(strrchr(location, '.')); | |
47 | 181 // add file to playlist |
641 | 182 playlist_load_ins_file_tuple(playlist, location, filename, pos, tuple); |
47 | 183 pos++; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
184 } |
47 | 185 |
641 | 186 g_free(location); |
187 location = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
188 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
189 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 find_track(xmlNode *tracklist, const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 xmlNode *nptr; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next){ |
641 | 195 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"track")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 add_file(nptr, filename, pos); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
197 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
200 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 static void |
641 | 202 find_audoptions(xmlNode *tracklist, const gchar *filename, gint pos) |
203 { | |
204 xmlNode *nptr; | |
884 | 205 Playlist *playlist = playlist_get_active(); |
206 | |
641 | 207 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next){ |
208 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"options")){ | |
209 xmlChar *opt = NULL; | |
210 | |
211 opt = xmlGetProp(nptr, (xmlChar *)"staticlist"); | |
212 if(!strcasecmp((char *)opt, "true")){ | |
884 | 213 playlist->attribute |= PLAYLIST_STATIC; |
641 | 214 } |
884 | 215 else |
216 playlist->attribute ^= PLAYLIST_STATIC; | |
217 xmlFree(opt); | |
218 opt = NULL; | |
641 | 219 } |
220 } | |
221 } | |
222 | |
223 static void | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 playlist_load_xspf(const gchar * filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
226 xmlDocPtr doc; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
227 xmlNode *nptr, *nptr2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 g_return_if_fail(filename != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 doc = xmlParseFile(filename); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 if (doc == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 |
641 | 235 xmlFree(base); |
236 base = NULL; | |
237 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 // find trackList |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) { |
641 | 240 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"playlist")){ |
241 base = (gchar *)xmlNodeGetBase(doc, nptr); | |
242 if(!strcmp(base, filename)) { | |
243 xmlFree(base); | |
244 base = NULL; | |
245 } | |
246 | |
247 for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next){ | |
248 | |
249 if(nptr2->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr2->name, (xmlChar *)"extension")){ | |
250 //check if application is audacious | |
251 xmlChar *app = NULL; | |
252 app = xmlGetProp(nptr2, (xmlChar *)"application"); | |
253 if(!xmlStrcmp(app, (xmlChar *)"audacious")) { | |
254 find_audoptions(nptr2, filename, pos); | |
255 } | |
256 xmlFree(app); | |
257 } | |
258 | |
259 if(nptr2->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr2->name, (xmlChar *)"trackList")){ | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 find_track(nptr2, filename, pos); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 } |
641 | 262 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
268 xmlFreeDoc(doc); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
269 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 playlist_save_xspf(const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 xmlDocPtr doc; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
276 xmlNodePtr rootnode, tmp, tracklist; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 GList *node; |
884 | 278 Playlist *playlist = playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 |
641 | 280 doc = xmlNewDoc((xmlChar *)"1.0"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
282 doc->charset = XML_CHAR_ENCODING_UTF8; |
641 | 283 doc->encoding = xmlStrdup((xmlChar *)"UTF-8"); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
284 |
641 | 285 rootnode = xmlNewNode(NULL, (xmlChar *)XSPF_ROOT_NODE_NAME); |
286 xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS); | |
287 xmlSetProp(rootnode, (xmlChar *)"version", (xmlChar *)"1"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 xmlDocSetRootElement(doc, rootnode); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 |
641 | 290 tmp = xmlNewNode(NULL, (xmlChar *)"creator"); |
291 xmlAddChild(tmp, xmlNewText((xmlChar *)PACKAGE "-" VERSION)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
292 xmlAddChild(rootnode, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
293 |
884 | 294 // add staticlist marker |
295 if(playlist->attribute & PLAYLIST_STATIC) { | |
296 xmlNodePtr extension, options; | |
297 | |
298 extension = xmlNewNode(NULL, (xmlChar *)"extension"); | |
299 xmlSetProp(extension, (xmlChar *)"application", (xmlChar *)"audacious"); | |
300 | |
301 options = xmlNewNode(NULL, (xmlChar *)"options"); | |
302 xmlSetProp(options, (xmlChar *)"staticlist", (xmlChar *)"true"); | |
303 | |
304 xmlAddChild(extension, options); | |
305 xmlAddChild(rootnode, extension); | |
306 } | |
307 | |
641 | 308 tracklist = xmlNewNode(NULL, (xmlChar *)"trackList"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 xmlAddChild(rootnode, tracklist); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 |
386
de15b9e09d2d
[svn] - updated m3u.c, xspf.c, pls.c to use the playlist->mutex and no more playlist_get
giacomo
parents:
384
diff
changeset
|
311 PLAYLIST_LOCK(playlist->mutex); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
87
diff
changeset
|
312 |
384
a91923634161
[svn] - don't use deprecated function playlist_get().
nenolod
parents:
361
diff
changeset
|
313 for (node = playlist->entries; node != NULL; node = g_list_next(node)) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 xmlNodePtr track, location; |
95 | 317 gchar *filename = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 |
641 | 319 track = xmlNewNode(NULL, (xmlChar *)"track"); |
320 location = xmlNewNode(NULL, (xmlChar *)"location"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
321 |
647 | 322 /* uri escape entry->filename */ |
323 if ( !strncasecmp("http://", entry->filename, 7) || | |
324 !strncasecmp("https://", entry->filename, 8) || | |
325 !strncasecmp("mms://", entry->filename, 6) ) /* streaming */ | |
326 { | |
327 gchar *tmp = (gchar *)xmlURIEscape((xmlChar *)entry->filename); | |
328 filename = g_strdup(tmp ? tmp : entry->filename); | |
329 g_free(tmp); | |
330 } | |
331 else /* local file */ | |
332 { | |
652
7f865e3cd285
[svn] - import xmlPathToURI() from libxml2-2.6.27 as audPathToURI(). this function is newly introduced at 2.6.27.
yaz
parents:
647
diff
changeset
|
333 gchar *tmp = (gchar *)audPathToURI((const xmlChar *)entry->filename); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
334 filename = g_strdup_printf("file://%s", tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
335 g_free(tmp); |
577
8182837f7a82
[svn] - don't percent encode urls beginning with http:// or https:// for now.
yaz
parents:
386
diff
changeset
|
336 } |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
337 |
95 | 338 if(!g_utf8_validate(filename, -1, NULL)) |
339 continue; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 |
641 | 341 xmlAddChild(location, xmlNewText((xmlChar *)filename)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 xmlAddChild(track, location); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 xmlAddChild(tracklist, track); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
344 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 /* do we have a tuple? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 if (entry->tuple != NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 { |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
348 if (entry->tuple->track_name != NULL && |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
349 g_utf8_validate(entry->tuple->track_name, -1, NULL)) |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
350 { |
641 | 351 tmp = xmlNewNode(NULL, (xmlChar *)"title"); |
352 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->track_name)); | |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
353 xmlAddChild(track, tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
354 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
355 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 if (entry->tuple->performer != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 g_utf8_validate(entry->tuple->performer, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 { |
641 | 359 tmp = xmlNewNode(NULL, (xmlChar *)"creator"); |
360 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->performer)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
361 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
363 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
364 if (entry->tuple->comment != NULL && |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
365 g_utf8_validate(entry->tuple->comment, -1, NULL)) |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
366 { |
641 | 367 tmp = xmlNewNode(NULL, (xmlChar *)"annotation"); |
368 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->comment)); | |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
369 xmlAddChild(track, tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
370 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
371 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 if (entry->tuple->album_name != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 g_utf8_validate(entry->tuple->album_name, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 { |
641 | 375 tmp = xmlNewNode(NULL, (xmlChar *)"album"); |
376 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->album_name)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
378 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
379 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 if (entry->tuple->track_number != 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
381 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
382 gchar *str; |
47 | 383 str = g_malloc(TMP_BUF_LEN); |
641 | 384 tmp = xmlNewNode(NULL, (xmlChar *)"trackNum"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
385 sprintf(str, "%d", entry->tuple->track_number); |
641 | 386 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 g_free(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
388 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
390 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
391 if (entry->tuple->length > 0) |
47 | 392 { |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
393 gchar *str; |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
394 str = g_malloc(TMP_BUF_LEN); |
641 | 395 tmp = xmlNewNode(NULL, (xmlChar *)"duration"); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
396 sprintf(str, "%d", entry->tuple->length); |
641 | 397 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
398 g_free(str); |
47 | 399 xmlAddChild(track, tmp); |
400 } | |
401 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
403 // additional metadata |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 // |
47 | 405 // year, date, genre, formatter, mtime |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
407 if (entry->tuple->year != 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 gchar *str; |
47 | 410 str = g_malloc(TMP_BUF_LEN); |
641 | 411 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
412 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"year"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 sprintf(str, "%d", entry->tuple->year); |
641 | 414 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
416 g_free(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
419 if (entry->tuple->date != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 g_utf8_validate(entry->tuple->date, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 { |
641 | 422 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
423 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"date"); | |
424 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->date)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
425 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
427 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
428 if (entry->tuple->genre != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 g_utf8_validate(entry->tuple->genre, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 { |
641 | 431 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
432 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"genre"); | |
433 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->genre)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
436 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
437 if (entry->tuple->formatter != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
438 g_utf8_validate(entry->tuple->formatter, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
439 { |
641 | 440 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
441 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"formatter"); | |
442 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->formatter)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
443 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
444 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
445 |
884 | 446 // mtime: write mtime unconditionally to support staticlist. |
447 { | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
448 gchar *str; |
47 | 449 str = g_malloc(TMP_BUF_LEN); |
641 | 450 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
451 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
452 sprintf(str, "%ld", (long) entry->tuple->mtime); |
884 | 453 |
641 | 454 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
455 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
456 g_free(str); |
884 | 457 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
458 } |
95 | 459 g_free(filename); |
460 filename = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
461 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
462 |
386
de15b9e09d2d
[svn] - updated m3u.c, xspf.c, pls.c to use the playlist->mutex and no more playlist_get
giacomo
parents:
384
diff
changeset
|
463 PLAYLIST_UNLOCK(playlist->mutex); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
87
diff
changeset
|
464 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
465 xmlSaveFormatFile(filename, doc, 1); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
466 xmlFreeDoc(doc); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
467 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
468 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
469 PlaylistContainer plc_xspf = { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
470 .name = "XSPF Playlist Format", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
471 .ext = "xspf", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 .plc_read = playlist_load_xspf, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
473 .plc_write = playlist_save_xspf, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
474 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
475 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 static void init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
477 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
478 playlist_container_register(&plc_xspf); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
479 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
480 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
481 static void cleanup(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
483 playlist_container_unregister(&plc_xspf); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
484 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
485 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 LowlevelPlugin llp_xspf = { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
487 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
489 "XSPF Playlist Format", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
490 init, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
491 cleanup, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
492 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
494 LowlevelPlugin *get_lplugin_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
495 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
496 return &llp_xspf; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
497 } |