Mercurial > audlegacy-plugins
annotate src/m3u/m3u.c @ 2286:4f84615468b7
Add .vfs_extensions to the timidity plugin. (Bugzilla #79)
author | Jack Kelly <weldingmaskman@hotmail.com> |
---|---|
date | Wed, 09 Jan 2008 09:24:30 -0600 |
parents | 9ddfa78b43a0 |
children | 42a5c9d5830b |
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 |
2215
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
21 /* #define AUD_DEBUG 1 */ |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
22 |
0
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 <glib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include <glib/gprintf.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 #include <time.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 #include <unistd.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 #include <sys/types.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #include <sys/stat.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 #include <sys/errno.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
1954
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1952
diff
changeset
|
36 #include <audacious/plugin.h> |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1675
diff
changeset
|
37 #include <audacious/main.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1675
diff
changeset
|
38 #include <audacious/util.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1675
diff
changeset
|
39 #include <audacious/playlist.h> |
1952
17a6441c71b6
Some missed #include "" to <> changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1950
diff
changeset
|
40 #include <audacious/playlist_container.h> |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1675
diff
changeset
|
41 #include <audacious/strings.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
44 parse_extm3u_info(const gchar * info, gchar ** title, gint * length) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 gchar *str; |
89 | 47 gchar *temp; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
48 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 g_return_if_fail(info != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 g_return_if_fail(title != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 g_return_if_fail(length != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
52 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
53 *title = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
54 *length = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
56 if (!aud_str_has_prefix_nocase(info, "#EXTINF:")) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 g_message("Invalid m3u metadata (%s)", info); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 info += 8; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 *length = atoi(info); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 if (*length <= 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
65 *length = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
66 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
67 *length *= 1000; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
68 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 if ((str = strchr(info, ','))) { |
89 | 70 temp = g_strstrip(g_strdup(str + 1)); |
71 if (strlen(temp) > 0) | |
72 *title = g_locale_to_utf8(temp, -1, NULL, NULL, NULL); | |
73 | |
74 g_free(temp); | |
75 temp = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
77 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 |
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 playlist_load_m3u(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 VFSFile *file; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 gchar *line; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
84 gchar *ext_info = NULL, *ext_title = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
85 gsize line_len = 1024; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 gint ext_len = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 gboolean is_extm3u = FALSE; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
88 Playlist *playlist = aud_playlist_get_active(); |
2215
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
89 gchar *uri = NULL; |
1252
551f76613eb2
Fix m3u loading for real.
William Pitcock <nenolod@atheme-project.org>
parents:
1251
diff
changeset
|
90 |
551f76613eb2
Fix m3u loading for real.
William Pitcock <nenolod@atheme-project.org>
parents:
1251
diff
changeset
|
91 uri = g_filename_to_uri(filename, NULL, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 |
1978 | 93 if ((file = aud_vfs_fopen(uri ? uri : filename, "rb")) == NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 |
2215
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
96 g_free(uri); uri = NULL; |
1252
551f76613eb2
Fix m3u loading for real.
William Pitcock <nenolod@atheme-project.org>
parents:
1251
diff
changeset
|
97 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 line = g_malloc(line_len); |
1978 | 99 while (aud_vfs_fgets(line, line_len, file)) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 line_len += 1024; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 line = g_realloc(line, line_len); |
1978 | 103 aud_vfs_fgets(&line[strlen(line)], 1024, file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
106 while (line[strlen(line) - 1] == '\r' || |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 line[strlen(line) - 1] == '\n') |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 line[strlen(line) - 1] = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
110 if (aud_str_has_prefix_nocase(line, "#EXTM3U")) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 is_extm3u = TRUE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
115 if (is_extm3u && aud_str_has_prefix_nocase(line, "#EXTINF:")) { |
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
116 aud_str_replace_in(&ext_info, g_strdup(line)); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 if (line[0] == '#' || strlen(line) == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 if (ext_info) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 g_free(ext_info); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 ext_info = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 if (is_extm3u) { |
2059
70b1f1fc4804
use aud_cfg in some places
William Pitcock <nenolod@atheme.org>
parents:
2057
diff
changeset
|
129 if (aud_cfg->use_pl_metadata && ext_info) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 parse_extm3u_info(ext_info, &ext_title, &ext_len); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 g_free(ext_info); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 ext_info = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
134 |
2215
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
135 uri = aud_construct_uri(line, filename); |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
136 AUDDBG("uri=%s\n", uri); |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
137 |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
138 /* add file only if valid uri has been constructed */ |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
139 if (uri) { |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
140 aud_playlist_load_ins_file(playlist, uri, filename, pos, ext_title, ext_len); |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
141 |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
142 if (pos >= 0) |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
143 pos++; |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
144 } |
9ddfa78b43a0
- now container plugins feed only valid uri to the core.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2059
diff
changeset
|
145 |
1665 | 146 g_free(uri); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
148 aud_str_replace_in(&ext_title, NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 ext_len = -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 |
1978 | 152 aud_vfs_fclose(file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 g_free(line); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
156 static void |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 playlist_save_m3u(const gchar *filename, gint pos) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
158 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 GList *node; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
160 gchar *outstr = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 VFSFile *file; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2053
diff
changeset
|
162 Playlist *playlist = aud_playlist_get_active(); |
1266
df2d1c5f3786
clean up r1265 as Crazy_Hopper suggests.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1265
diff
changeset
|
163 gchar *fn = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 g_return_if_fail(filename != NULL); |
384
a91923634161
[svn] - don't use deprecated function playlist_get().
nenolod
parents:
362
diff
changeset
|
166 g_return_if_fail(playlist != NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
167 |
1266
df2d1c5f3786
clean up r1265 as Crazy_Hopper suggests.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1265
diff
changeset
|
168 fn = g_filename_to_uri(filename, NULL, NULL); |
1978 | 169 file = aud_vfs_fopen(fn ? fn : filename, "wb"); |
1665 | 170 g_free(fn); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 g_return_if_fail(file != NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
172 |
2059
70b1f1fc4804
use aud_cfg in some places
William Pitcock <nenolod@atheme.org>
parents:
2057
diff
changeset
|
173 if (aud_cfg->use_pl_metadata) |
1978 | 174 aud_vfs_fprintf(file, "#EXTM3U\n"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
175 |
1675
ae9b0327b620
Fix plugins to conform with PLAYLIST_{UN}LOCK() change.
Matti Hamalainen <ccr@tnsp.org>
parents:
1665
diff
changeset
|
176 PLAYLIST_LOCK(playlist); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
90
diff
changeset
|
177 |
384
a91923634161
[svn] - don't use deprecated function playlist_get().
nenolod
parents:
362
diff
changeset
|
178 for (node = playlist->entries; node; node = g_list_next(node)) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 |
2059
70b1f1fc4804
use aud_cfg in some places
William Pitcock <nenolod@atheme.org>
parents:
2057
diff
changeset
|
181 if (entry->title && aud_cfg->use_pl_metadata) { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
182 gint seconds; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
184 if (entry->length > 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
185 seconds = (entry->length) / 1000; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
186 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
187 seconds = -1; |
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 outstr = g_locale_from_utf8(entry->title, -1, NULL, NULL, NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 if(outstr) { |
1978 | 191 aud_vfs_fprintf(file, "#EXTINF:%d,%s\n", seconds, outstr); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 g_free(outstr); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 outstr = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 } else { |
1978 | 195 aud_vfs_fprintf(file, "#EXTINF:%d,%s\n", seconds, entry->title); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 } |
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 |
1252
551f76613eb2
Fix m3u loading for real.
William Pitcock <nenolod@atheme-project.org>
parents:
1251
diff
changeset
|
199 fn = g_filename_from_uri(entry->filename, NULL, NULL); |
1978 | 200 aud_vfs_fprintf(file, "%s\n", fn ? fn : entry->filename); |
1665 | 201 g_free(fn); |
0
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 |
1675
ae9b0327b620
Fix plugins to conform with PLAYLIST_{UN}LOCK() change.
Matti Hamalainen <ccr@tnsp.org>
parents:
1665
diff
changeset
|
204 PLAYLIST_UNLOCK(playlist); |
92
fadf346ddde3
[svn] - pls doesn't go along with PLAYLIST_LOCK in playlist_save().
yaz
parents:
90
diff
changeset
|
205 |
1978 | 206 aud_vfs_fclose(file); |
0
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 PlaylistContainer plc_m3u = { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 .name = "M3U Playlist Format", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 .ext = "m3u", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 .plc_read = playlist_load_m3u, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 .plc_write = playlist_save_m3u, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 static void init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
217 { |
2053
059bd21a0c80
PlaylistContainer API updates
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
218 aud_playlist_container_register(&plc_m3u); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
219 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 static void cleanup(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
222 { |
2053
059bd21a0c80
PlaylistContainer API updates
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
223 aud_playlist_container_unregister(&plc_m3u); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1268
diff
changeset
|
226 DECLARE_PLUGIN(m3u, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL); |