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.
This commit is contained in:
Max Kellermann 2010-06-25 22:43:35 +02:00
parent fba13bd5d2
commit c27fc26ecd
1 changed files with 23 additions and 3 deletions

View File

@ -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);
@ -217,6 +217,26 @@ playlist_list_open_stream_mime(struct input_stream *is)
return NULL;
}
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)
{