Index: shell/rb-playlist-manager.c
===================================================================
--- shell/rb-playlist-manager.c	(revision 5921)
+++ shell/rb-playlist-manager.c	(working copy)
@@ -625,75 +625,6 @@
 			RB_STATIC_PLAYLIST_SOURCE (rb_playlist_manager_new_playlist (mgr, title, FALSE));
 }
 
-/**
- * rb_playlist_manager_parse_file:
- * @mgr: the #RBPlaylistManager
- * @uri: URI of the playlist to load
- * @error: returns a GError in case of error
- *
- * Parses a playlist file, adding entries to the database and to a new
- * static playlist.  If the playlist file includes a title, the static
- * playlist created will have the same title.
- *
- * Return value: TRUE on success
- **/
-gboolean
-rb_playlist_manager_parse_file (RBPlaylistManager *mgr, const char *uri, GError **error)
-{
-	rb_debug ("loading playlist from %s", uri);
-
-	g_signal_emit (mgr, rb_playlist_manager_signals[PLAYLIST_LOAD_START], 0);
-
-	{
-		TotemPlParser *parser = totem_pl_parser_new ();
-
-		g_signal_connect_object (parser, "entry-parsed",
-					 G_CALLBACK (handle_playlist_entry_cb),
-					 mgr, 0);
-
-		g_signal_connect_object (parser, "playlist-started",
-					 G_CALLBACK (playlist_load_started_cb),
-					 mgr, 0);
-
-		g_object_set (parser, "recurse", FALSE, NULL);
-
-		if (totem_pl_parser_parse (parser, uri, TRUE) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
-			g_set_error (error,
-				     RB_PLAYLIST_MANAGER_ERROR,
-				     RB_PLAYLIST_MANAGER_ERROR_PARSE,
-				     "%s",
-				     _("The playlist file may be in an unknown format or corrupted."));
-			return FALSE;
-		}
-
-		if (mgr->priv->loading_playlist != NULL) {
-			char *name = NULL;
-
-			/* totem-plparser may not have given us the playlist name */
-			g_object_get (mgr->priv->loading_playlist, "name", &name, NULL);
-			if (name == NULL || name[0] == '\0') {
-				char *path;
-
-				rb_debug ("setting playlist name from file name");
-				path = g_filename_from_uri (uri, NULL, NULL);
-				if (path) {
-					name = g_path_get_basename (path);
-					g_object_set (mgr->priv->loading_playlist, "name", name, NULL);
-					g_free (path);
-				}
-			}
-
-			g_free (name);
-			mgr->priv->loading_playlist = NULL;
-		}
-
-		g_object_unref (parser);
-	}
-
-	g_signal_emit (mgr, rb_playlist_manager_signals[PLAYLIST_LOAD_FINISH], 0);
-	return TRUE;
-}
-
 static void
 append_new_playlist_source (RBPlaylistManager *mgr, RBPlaylistSource *source)
 {
@@ -1877,3 +1808,96 @@
 					  m3u_format);
 	return TRUE;
 }
+
+/**
+ * rb_playlist_manager_parse_file:
+ * @mgr: the #RBPlaylistManager
+ * @uri: URI of the playlist to load
+ * @error: returns a GError in case of error
+ *
+ * Parses a playlist file, adding entries to the database and to a new
+ * static playlist.  If the playlist file includes a title, the static
+ * playlist created will have the same title.
+ *
+ * Return value: TRUE on success
+ **/
+gboolean
+rb_playlist_manager_parse_file (RBPlaylistManager *mgr, const char *uri, GError **error)
+{
+	rb_debug ("loading playlist from %s", uri);
+
+	g_signal_emit (mgr, rb_playlist_manager_signals[PLAYLIST_LOAD_START], 0);
+
+	{
+		TotemPlParser *parser = totem_pl_parser_new ();
+
+		g_signal_connect_object (parser, "entry-parsed",
+					 G_CALLBACK (handle_playlist_entry_cb),
+					 mgr, 0);
+
+		g_signal_connect_object (parser, "playlist-started",
+					 G_CALLBACK (playlist_load_started_cb),
+					 mgr, 0);
+
+		g_object_set (parser, "recurse", FALSE, NULL);
+
+		if (totem_pl_parser_parse (parser, uri, TRUE) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
+			g_set_error (error,
+				     RB_PLAYLIST_MANAGER_ERROR,
+				     RB_PLAYLIST_MANAGER_ERROR_PARSE,
+				     "%s",
+				     _("The playlist file may be in an unknown format or corrupted."));
+			return FALSE;
+		}
+
+		if (mgr->priv->loading_playlist != NULL) {
+			char *name = NULL;
+
+			/* totem-plparser may not have given us the playlist name */
+			g_object_get (mgr->priv->loading_playlist, "name", &name, NULL);
+			if (name == NULL || name[0] == '\0') {
+				char *path;
+
+				rb_debug ("setting playlist name from file name");
+				path = g_filename_from_uri (uri, NULL, NULL);
+				if (path) {
+					int i;
+					gchar **filename_array = NULL;
+
+					name = g_path_get_basename (path);
+
+					for (i = 0; i < G_N_ELEMENTS (playlist_export_formats); i++) {
+						int j;
+
+						/* try to match the playlist type with the extension */
+						for (j = 0; playlist_export_formats[i].extensions[j] != NULL; j++) {
+							if (g_str_has_suffix (name, playlist_export_formats[i].extensions[j])) {
+								char *delimiter = g_strconcat(".", playlist_export_formats[i].extensions[j], NULL);
+
+								filename_array = g_strsplit(name, delimiter, 0);
+								g_free(name);
+								g_free(delimiter);
+								name = g_strdup(filename_array[0]);
+								break;
+							}
+						}
+					}
+
+					g_object_set (mgr->priv->loading_playlist, "name", name, NULL);
+					g_strfreev(filename_array);
+					g_free (path);
+				}
+			}
+
+			g_free (name);
+			mgr->priv->loading_playlist = NULL;
+		}
+
+		g_object_unref (parser);
+	}
+
+	g_signal_emit (mgr, rb_playlist_manager_signals[PLAYLIST_LOAD_FINISH], 0);
+	return TRUE;
+}
+
+
