aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_list.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-06-25 22:43:35 +0200
committerMax Kellermann <max@duempel.org>2010-06-25 22:43:52 +0200
commitc27fc26ecd7312d6a1678990838d4c457986e161 (patch)
tree913abd7359294267e03801d6faab46ec94d1a19b /src/playlist_list.c
parentfba13bd5d218f0fd73d2f4017302aef9d075b35c (diff)
downloadmpd-c27fc26ecd7312d6a1678990838d4c457986e161.tar.gz
mpd-c27fc26ecd7312d6a1678990838d4c457986e161.tar.xz
mpd-c27fc26ecd7312d6a1678990838d4c457986e161.zip
playlist_list: probe plugin without MIME attributes
If the MIME type of a stream contains a semicolon, remove it and the text after it to probe for a playlist plugin.
Diffstat (limited to 'src/playlist_list.c')
-rw-r--r--src/playlist_list.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/playlist_list.c b/src/playlist_list.c
index 35c04d533..9c40e6dfe 100644
--- a/src/playlist_list.c
+++ b/src/playlist_list.c
@@ -190,12 +190,12 @@ playlist_list_open_uri(const char *uri)
}
static struct playlist_provider *
-playlist_list_open_stream_mime(struct input_stream *is)
+playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
{
struct playlist_provider *playlist;
assert(is != NULL);
- assert(is->mime != NULL);
+ assert(mime != NULL);
for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
const struct playlist_plugin *plugin = playlist_plugins[i];
@@ -203,7 +203,7 @@ playlist_list_open_stream_mime(struct input_stream *is)
if (playlist_plugins_enabled[i] &&
plugin->open_stream != NULL &&
plugin->mime_types != NULL &&
- string_array_contains(plugin->mime_types, is->mime)) {
+ string_array_contains(plugin->mime_types, mime)) {
/* rewind the stream, so each plugin gets a
fresh start */
input_stream_seek(is, 0, SEEK_SET, NULL);
@@ -218,6 +218,26 @@ playlist_list_open_stream_mime(struct input_stream *is)
}
static struct playlist_provider *
+playlist_list_open_stream_mime(struct input_stream *is)
+{
+ assert(is->mime != NULL);
+
+ const char *semicolon = strchr(is->mime, ';');
+ if (semicolon == NULL)
+ return playlist_list_open_stream_mime2(is, is->mime);
+
+ if (semicolon == is->mime)
+ return NULL;
+
+ /* probe only the portion before the semicolon*/
+ char *mime = g_strndup(is->mime, semicolon - is->mime);
+ struct playlist_provider *playlist =
+ playlist_list_open_stream_mime2(is, mime);
+ g_free(mime);
+ return playlist;
+}
+
+static struct playlist_provider *
playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
{
struct playlist_provider *playlist;