Add a check for an extended M3U playlist header. Helps
it not rely on playlist URL being suffixed with .m3u.

Was assuming there is only one extended M3U attribute between
track URLs, this is not true and will cause errors (see random invalid
id mlib errors).

Added ability to set mlib title property, tries to be smart about
it by trimming whitespace and leaving it alone if the string is empty.

I suspect this resolves 423 and 443 (and other unreported bugs)
with the addition of the title capabilites and the fact that
xforms don't export playlists anymore(but m3u now adds magic checks).
---
 src/plugins/m3u/m3u.c |   46 ++++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/plugins/m3u/m3u.c b/src/plugins/m3u/m3u.c
index 4511d87..6e9e0fa 100644
--- a/src/plugins/m3u/m3u.c
+++ b/src/plugins/m3u/m3u.c
@@ -50,6 +50,8 @@ XMMS_XFORM_PLUGIN ("m3u",
                    "Playlist parser for m3u's",
                    xmms_m3u_plugin_setup);
 
+/* xform methods */
+
 static gboolean
 xmms_m3u_plugin_setup (xmms_xform_plugin_t *xform_plugin)
 {
@@ -67,6 +69,9 @@ xmms_m3u_plugin_setup (xmms_xform_plugin_t *xform_plugin)
                                      "audio/x-mpegurl",
                                      NULL);
 
+       xmms_magic_add ("Extended M3U header", "audio/x-mpegurl",
+                       "0 string #EXTM3U", NULL);
+
        xmms_magic_extension_add ("audio/x-mpegurl", "*.m3u");
 
        return TRUE;
@@ -82,10 +87,6 @@ xmms_m3u_init (xmms_xform_t *xform)
        return TRUE;
 }
 
-/*
- * Member functions
- */
-
 static gboolean
 xmms_m3u_browse (xmms_xform_t *xform,
                  const gchar *url,
@@ -93,7 +94,6 @@ xmms_m3u_browse (xmms_xform_t *xform,
 {
        gchar line[XMMS_XFORM_MAX_LINE_SIZE];
        xmms_error_t err;
-       gboolean extm3u = FALSE;
        gchar *tmp;
        const gchar *d;
 
@@ -102,31 +102,37 @@ xmms_m3u_browse (xmms_xform_t *xform,
        xmms_error_reset (&err);
 
        if (!xmms_xform_read_line (xform, line, &err)) {
-               XMMS_DBG ("Error reading m3u-file");
+               XMMS_DBG ("Error reading m3u file");
                return FALSE;
        }
 
-       if (strcmp (line, "#EXTM3U") == 0) {
-               extm3u = TRUE;
-               if (!xmms_xform_read_line (xform, line, &err)) {
-                       return FALSE;
-               }
-       }
-
        d = xmms_xform_get_url (xform);
 
+
+       gchar *title = NULL;
        do {
                if (line[0] == '#') {
-                       if (!xmms_xform_read_line (xform, line, &err)) {
-                               return FALSE;
+                       if (!title && !strncmp (&line[1], "EXTINF", 6) &&
+                          (tmp = strchr (&line[6], ',') + 1)) {
+                               title = g_strstrip(g_strdup (tmp));
                        }
+               } else {
+                       tmp = xmms_build_playlist_url (d, line);
+                       xmms_xform_browse_add_symlink (xform, NULL, tmp);
+
+                       if (title) {
+                               if (*title) {
+                                       
xmms_xform_browse_add_entry_property_str (xform,
+                                                                               
  "title",
+                                                                               
  title);
+                               }
+                               g_free (title);
+                               title = NULL;
+                       }
+                       
+                       g_free (tmp);
                }
 
-               tmp = xmms_build_playlist_url (d, line);
-               xmms_xform_browse_add_symlink (xform, NULL, tmp);
-
-               g_free (tmp);
-
        } while (xmms_xform_read_line (xform, line, &err));
 
        return TRUE;
-- 
1.6.0.4


--
_______________________________________________
Xmms2-devel mailing list
Xmms2-devel@lists.xmms.se
http://lists.xmms.se/cgi-bin/mailman/listinfo/xmms2-devel
  • m3u plugin fixed Anthony Garcia
    • [PATCH] BUG(423,443): EXTM3U, silly assumptions, title... Anthony Garcia

Reply via email to