Mercurial > audlegacy-plugins
annotate src/xspf/xspf.c @ 688:43c77973e494 trunk
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
extensive testing will be needed.
author | nenolod |
---|---|
date | Tue, 20 Feb 2007 06:17:27 -0800 |
parents | f46c9abe09d4 |
children | 4fd90f2d1832 |
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 gboolean override_mtime = FALSE; | |
53 | |
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
|
54 // 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
|
55 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
|
56 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
|
57 { |
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 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
|
59 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
|
60 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
|
61 |
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 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
|
63 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
|
64 |
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 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
|
66 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
|
67 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
|
68 } |
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 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 } |
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
|
78 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
79 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 add_file(xmlNode *track, const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 xmlNode *nptr; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 TitleInput *tuple; |
641 | 84 gchar *location = NULL; |
361
f201074bf69a
[svn] - update playlist code. M3U was simple and did not require anything special.
nenolod
parents:
95
diff
changeset
|
85 Playlist *playlist = playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 tuple = bmp_title_input_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 |
657 | 89 // staticlist hack |
90 tuple->mtime = -1; // mark as uninitialized. | |
641 | 91 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 // creator, album, title, duration, trackNum, annotation, image, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
93 for(nptr = track->children; nptr != NULL; nptr = nptr->next){ |
641 | 94 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"location")){ |
95 gchar *str = (gchar *)xmlNodeGetContent(nptr); | |
657 | 96 gchar *tmp; |
97 | |
98 if( strncmp(str, "http://", 7) && strncmp(str, "https://", 8) && | |
99 strncmp(str, "mms://", 6) ) { /* not a streaming */ | |
100 tmp = (gchar *)xmlURIUnescapeString(str, -1, NULL); | |
101 } | |
102 else { /* streaming */ | |
103 tmp = g_strdup(str); | |
104 } | |
641 | 105 |
106 if(strstr(tmp, "file://")){ | |
107 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
|
108 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
109 else { |
641 | 110 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
|
111 } |
641 | 112 xmlFree(str); g_free(tmp); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
113 } |
641 | 114 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
|
115 tuple->track_name = (gchar *)xmlNodeGetContent(nptr); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
116 } |
641 | 117 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
|
118 tuple->performer = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 } |
641 | 120 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
|
121 tuple->comment = (gchar *)xmlNodeGetContent(nptr); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
122 continue; |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
123 } |
641 | 124 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
|
125 tuple->album_name = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 } |
641 | 127 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
|
128 xmlChar *str = xmlNodeGetContent(nptr); |
641 | 129 tuple->track_number = atol((char *)str); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 xmlFree(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 } |
641 | 132 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
|
133 xmlChar *str = xmlNodeGetContent(nptr); |
641 | 134 tuple->length = atol((char *)str); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
135 xmlFree(str); |
47 | 136 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 // additional metadata |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
140 // |
641 | 141 // year, date, genre, formatter, mtime |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 // |
641 | 143 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
|
144 xmlChar *rel = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 |
641 | 146 rel = xmlGetProp(nptr, (xmlChar *)"rel"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 |
641 | 148 if(!xmlStrcmp(rel, (xmlChar *)"year")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 xmlChar *cont = xmlNodeGetContent(nptr); |
641 | 150 tuple->year = atol((char *)cont); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 xmlFree(cont); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 } |
641 | 154 else if(!xmlStrcmp(rel, (xmlChar *)"date")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 tuple->date = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
156 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 } |
641 | 158 else if(!xmlStrcmp(rel, (xmlChar *)"genre")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 tuple->genre = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
160 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 } |
641 | 162 else if(!xmlStrcmp(rel, (xmlChar *)"formatter")){ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 tuple->formatter = (gchar *)xmlNodeGetContent(nptr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 } |
641 | 166 else if(!xmlStrcmp(rel, (xmlChar *)"mtime")){ |
47 | 167 xmlChar *str = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 str = xmlNodeGetContent(nptr); |
641 | 169 tuple->mtime = (time_t)atoll((char *)str); |
47 | 170 xmlFree(str); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
173 xmlFree(rel); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 rel = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 } |
87
fabe64e89949
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
47
diff
changeset
|
178 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 if (tuple->length == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 tuple->length = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 } |
47 | 182 |
657 | 183 if(override_mtime) { |
184 tuple->mtime = 0; //when mtime=0, scanning will be skipped. --yaz | |
185 } | |
47 | 186 |
641 | 187 if(location){ |
188 tuple->file_name = g_path_get_basename(location); | |
189 tuple->file_path = g_path_get_dirname(location); | |
190 tuple->file_ext = g_strdup(strrchr(location, '.')); | |
47 | 191 // add file to playlist |
641 | 192 playlist_load_ins_file_tuple(playlist, location, filename, pos, tuple); |
47 | 193 pos++; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 } |
47 | 195 |
641 | 196 g_free(location); |
197 location = NULL; | |
0
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 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 find_track(xmlNode *tracklist, const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 xmlNode *nptr; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next){ |
641 | 205 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
|
206 add_file(nptr, filename, pos); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
209 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 static void |
641 | 212 find_audoptions(xmlNode *tracklist, const gchar *filename, gint pos) |
213 { | |
214 xmlNode *nptr; | |
215 for(nptr = tracklist->children; nptr != NULL; nptr = nptr->next){ | |
216 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"options")){ | |
217 xmlChar *opt = NULL; | |
218 | |
219 opt = xmlGetProp(nptr, (xmlChar *)"staticlist"); | |
220 if(!strcasecmp((char *)opt, "true")){ | |
221 override_mtime = TRUE; | |
222 } | |
223 xmlFree(opt); | |
224 opt = NULL; | |
225 } | |
226 } | |
227 } | |
228 | |
229 static void | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 playlist_load_xspf(const gchar * filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 xmlDocPtr doc; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 xmlNode *nptr, *nptr2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 g_return_if_fail(filename != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 doc = xmlParseFile(filename); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 if (doc == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 |
641 | 241 xmlFree(base); |
242 base = NULL; | |
243 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 // find trackList |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
245 for(nptr = doc->children; nptr != NULL; nptr = nptr->next) { |
641 | 246 if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"playlist")){ |
247 base = (gchar *)xmlNodeGetBase(doc, nptr); | |
248 if(!strcmp(base, filename)) { | |
249 xmlFree(base); | |
250 base = NULL; | |
251 } | |
252 | |
253 for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next){ | |
254 | |
255 if(nptr2->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr2->name, (xmlChar *)"extension")){ | |
256 //check if application is audacious | |
257 xmlChar *app = NULL; | |
258 app = xmlGetProp(nptr2, (xmlChar *)"application"); | |
259 if(!xmlStrcmp(app, (xmlChar *)"audacious")) { | |
260 find_audoptions(nptr2, filename, pos); | |
261 } | |
262 xmlFree(app); | |
263 } | |
264 | |
265 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
|
266 find_track(nptr2, filename, pos); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 } |
641 | 268 |
0
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 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 xmlFreeDoc(doc); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
276 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 playlist_save_xspf(const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
280 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 xmlDocPtr doc; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 xmlNodePtr rootnode, tmp, tracklist; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 GList *node; |
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
|
284 Playlist *playlist = playlist_get_active(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 |
641 | 286 doc = xmlNewDoc((xmlChar *)"1.0"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
288 doc->charset = XML_CHAR_ENCODING_UTF8; |
641 | 289 doc->encoding = xmlStrdup((xmlChar *)"UTF-8"); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
290 |
641 | 291 rootnode = xmlNewNode(NULL, (xmlChar *)XSPF_ROOT_NODE_NAME); |
292 xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS); | |
293 xmlSetProp(rootnode, (xmlChar *)"version", (xmlChar *)"1"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 xmlDocSetRootElement(doc, rootnode); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 |
641 | 296 tmp = xmlNewNode(NULL, (xmlChar *)"creator"); |
297 xmlAddChild(tmp, xmlNewText((xmlChar *)PACKAGE "-" VERSION)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 xmlAddChild(rootnode, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 |
641 | 300 tracklist = xmlNewNode(NULL, (xmlChar *)"trackList"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
301 xmlAddChild(rootnode, tracklist); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 |
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
|
303 PLAYLIST_LOCK(playlist->mutex); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
87
diff
changeset
|
304 |
384
a91923634161
[svn] - don't use deprecated function playlist_get().
nenolod
parents:
361
diff
changeset
|
305 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
|
306 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 xmlNodePtr track, location; |
95 | 309 gchar *filename = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 |
641 | 311 track = xmlNewNode(NULL, (xmlChar *)"track"); |
312 location = xmlNewNode(NULL, (xmlChar *)"location"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 |
647 | 314 /* uri escape entry->filename */ |
315 if ( !strncasecmp("http://", entry->filename, 7) || | |
316 !strncasecmp("https://", entry->filename, 8) || | |
317 !strncasecmp("mms://", entry->filename, 6) ) /* streaming */ | |
318 { | |
319 gchar *tmp = (gchar *)xmlURIEscape((xmlChar *)entry->filename); | |
320 filename = g_strdup(tmp ? tmp : entry->filename); | |
321 g_free(tmp); | |
322 } | |
323 else /* local file */ | |
324 { | |
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
|
325 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
|
326 filename = g_strdup_printf("file://%s", tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
327 g_free(tmp); |
577
8182837f7a82
[svn] - don't percent encode urls beginning with http:// or https:// for now.
yaz
parents:
386
diff
changeset
|
328 } |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
329 |
95 | 330 if(!g_utf8_validate(filename, -1, NULL)) |
331 continue; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
332 |
641 | 333 xmlAddChild(location, xmlNewText((xmlChar *)filename)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
334 xmlAddChild(track, location); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
335 xmlAddChild(tracklist, track); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
336 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 /* do we have a tuple? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 if (entry->tuple != NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 { |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
340 if (entry->tuple->track_name != NULL && |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
341 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
|
342 { |
641 | 343 tmp = xmlNewNode(NULL, (xmlChar *)"title"); |
344 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
|
345 xmlAddChild(track, tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
346 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
347 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
348 if (entry->tuple->performer != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
349 g_utf8_validate(entry->tuple->performer, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 { |
641 | 351 tmp = xmlNewNode(NULL, (xmlChar *)"creator"); |
352 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->performer)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
354 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
356 if (entry->tuple->comment != NULL && |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
357 g_utf8_validate(entry->tuple->comment, -1, NULL)) |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
358 { |
641 | 359 tmp = xmlNewNode(NULL, (xmlChar *)"annotation"); |
360 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->comment)); | |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
361 xmlAddChild(track, tmp); |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
362 } |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
363 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
364 if (entry->tuple->album_name != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 g_utf8_validate(entry->tuple->album_name, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 { |
641 | 367 tmp = xmlNewNode(NULL, (xmlChar *)"album"); |
368 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->album_name)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
369 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
371 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 if (entry->tuple->track_number != 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 gchar *str; |
47 | 375 str = g_malloc(TMP_BUF_LEN); |
641 | 376 tmp = xmlNewNode(NULL, (xmlChar *)"trackNum"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 sprintf(str, "%d", entry->tuple->track_number); |
641 | 378 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
379 g_free(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 xmlAddChild(track, tmp); |
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 |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
383 if (entry->tuple->length > 0) |
47 | 384 { |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
385 gchar *str; |
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
386 str = g_malloc(TMP_BUF_LEN); |
641 | 387 tmp = xmlNewNode(NULL, (xmlChar *)"duration"); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
388 sprintf(str, "%d", entry->tuple->length); |
641 | 389 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
585
2d20bc58a290
[svn] tweak xspf plugin to conform xspf specification version 1.
yaz
parents:
577
diff
changeset
|
390 g_free(str); |
47 | 391 xmlAddChild(track, tmp); |
392 } | |
393 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
394 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 // additional metadata |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 // |
47 | 397 // year, date, genre, formatter, mtime |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 // |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 if (entry->tuple->year != 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
400 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 gchar *str; |
47 | 402 str = g_malloc(TMP_BUF_LEN); |
641 | 403 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
404 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"year"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 sprintf(str, "%d", entry->tuple->year); |
641 | 406 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
407 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 g_free(str); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 if (entry->tuple->date != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 g_utf8_validate(entry->tuple->date, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 { |
641 | 414 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
415 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"date"); | |
416 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->date)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 xmlAddChild(track, tmp); |
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 if (entry->tuple->genre != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 g_utf8_validate(entry->tuple->genre, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 { |
641 | 423 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
424 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"genre"); | |
425 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->genre)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 xmlAddChild(track, tmp); |
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 if (entry->tuple->formatter != NULL && |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 g_utf8_validate(entry->tuple->formatter, -1, NULL)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
431 { |
641 | 432 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
433 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"formatter"); | |
434 xmlAddChild(tmp, xmlNewText((xmlChar *)entry->tuple->formatter)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 xmlAddChild(track, tmp); |
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 |
641 | 438 // mtime: write mtime unconditionally for staticlist hack. |
439 // if (entry->tuple->mtime) { | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
440 gchar *str; |
47 | 441 str = g_malloc(TMP_BUF_LEN); |
641 | 442 tmp = xmlNewNode(NULL, (xmlChar *)"meta"); |
443 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime"); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
444 sprintf(str, "%ld", (long) entry->tuple->mtime); |
641 | 445 xmlAddChild(tmp, xmlNewText((xmlChar *)str)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
446 xmlAddChild(track, tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
447 g_free(str); |
641 | 448 // } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
449 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
450 } |
95 | 451 g_free(filename); |
452 filename = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
453 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 |
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
|
455 PLAYLIST_UNLOCK(playlist->mutex); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
87
diff
changeset
|
456 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
457 xmlSaveFormatFile(filename, doc, 1); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
458 xmlFreeDoc(doc); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
459 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
460 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
461 PlaylistContainer plc_xspf = { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
462 .name = "XSPF Playlist Format", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
463 .ext = "xspf", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
464 .plc_read = playlist_load_xspf, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
465 .plc_write = playlist_save_xspf, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
466 }; |
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 static void init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
469 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
470 playlist_container_register(&plc_xspf); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
471 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
473 static void cleanup(void) |
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 playlist_container_unregister(&plc_xspf); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 } |
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 LowlevelPlugin llp_xspf = { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
479 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
480 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
481 "XSPF Playlist Format", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 init, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
483 cleanup, |
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 *get_lplugin_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
487 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 return &llp_xspf; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
489 } |