After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 375665 - xspf playlists
xspf playlists
Status: RESOLVED OBSOLETE
Product: rhythmbox
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
Depends on: 361531 551393 605313
Blocks:
 
 
Reported: 2006-11-15 20:01 UTC by William Jon McCann
Modified: 2018-05-24 12:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Adds support for xspf, iriver pla playlists (4.68 KB, patch)
2008-05-06 05:07 UTC, Martin Franco
none Details | Review
add xspf playlist support, and import of iriver playlist (1.42 KB, patch)
2008-05-12 19:10 UTC, Martin Franco
committed Details | Review

Description William Jon McCann 2006-11-15 20:01:06 UTC
It might be nice to support XSPF playlists.

http://www.xspf.org/

I came across this while looking for a good XML format to use with XSLT to produce track-list printouts for playlists/CDs.

Might also be nice to adopt this for internal use too.
Comment 1 William Jon McCann 2006-11-15 20:31:12 UTC
Looks like totem supports XSPF but... it seems like there is no way with the current API to add tags since the iter func is:

typedef void (*TotemPlParserIterFunc) (GtkTreeModel *model, GtkTreeIter *iter,
				       char **uri, char **title,
				       gboolean *custom_title,
				       gpointer user_data);

At the least we should be able to support all the standard XSPF tags.  The spec seems to support extensions too which would be a nice way to add RB specific stuff.

Maybe we can do:

typedef void (*TotemPlParserIterFunc) (GtkTreeModel *model, 
                                       GtkTreeIter  *iter,
				       int           requested_fields,
				       GHashTable   *fields,
				       gpointer      user_data);
Where requested_fields is set like:

requested_fields = TOTEM_PL_FIELD_TITLE | TOTEM_PL_FIELD_ARTIST;

And the hash is filled like:

if (requested_fields & TOTEM_PL_FIELD_TITLE) 
  g_hash_table_insert (properties, TOTEM_PL_FIELD_TITLE_STR, "Foo");

A reason for using a string as the key would be so that you can do:

  g_hash_table_insert (properties, "X-Rhythmbox-whatever", "blah");


Thoughts?
Comment 2 Bastien Nocera 2006-11-15 20:34:18 UTC
See also bug 361531, which is about loading that extra metadata. Patches more than welcome, especially as we're still not frozen :)
Comment 3 Bastien Nocera 2007-03-31 00:20:56 UTC
I didn't notice that the problem was about saving metadata using totem.

I'm pretty sure it would be possible to extend .pls, or .xspf support to handle saving extra metadata. Please file a separate bug. bug 361531 was about handling *reading* the extra metadata from the playlists, not saving it.
Comment 4 Martin Franco 2008-05-06 05:07:59 UTC
Created attachment 110436 [details] [review]
Adds support for xspf, iriver pla playlists
Comment 5 Jonathan Matthew 2008-05-06 06:27:53 UTC
The patch generally looks good to me, but I don't think it's a good idea to add iriver playlists to the UI.  They're basically useless anywhere other than on an iriver device that supports them.
Comment 6 Martin Franco 2008-05-12 19:10:31 UTC
Created attachment 110794 [details] [review]
add xspf playlist support, and import of iriver playlist
Comment 7 Martin Franco 2008-05-12 19:28:07 UTC
Comment on attachment 110794 [details] [review]
add xspf playlist support, and import of iriver playlist

Index: sources/rb-playlist-source.c
===================================================================
--- sources/rb-playlist-source.c	(revision 5700)
+++ sources/rb-playlist-source.c	(working copy)
@@ -55,6 +55,8 @@
 #include "rb-static-playlist-source.h"
 #include "rb-auto-playlist-source.h"
 
+#include "rb-playlist-manager.h"
+
 /**
  * SECTION:rb-playlist-source
  * @short_description: Base class for playlist sources
@@ -593,11 +595,12 @@
 void
 rb_playlist_source_save_playlist (RBPlaylistSource *source,
 				  const char *uri,
-				  gboolean m3u_format)
+				  gint format)
 {
 	TotemPlParser *playlist;
 	GError *error = NULL;
 	char *name;
+	gint format_number;
 
 	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
 
@@ -606,9 +609,20 @@
 
 	g_object_get (source, "name", &name, NULL);
 
+	switch(format) {
+	case RB_PLAYLIST_EXPORT_TYPE_XSPF:
+		format_number = TOTEM_PL_PARSER_XSPF;
+		break;
+	case RB_PLAYLIST_EXPORT_TYPE_M3U:
+		format_number = TOTEM_PL_PARSER_M3U;
+		break;
+	default:
+		format_number = TOTEM_PL_PARSER_PLS;
+		break;
+	};
 	totem_pl_parser_write_with_title (playlist, GTK_TREE_MODEL (source->priv->model),
 					  playlist_iter_func, uri, name,
-					  m3u_format ? TOTEM_PL_PARSER_M3U : TOTEM_PL_PARSER_PLS,
+					  format_number,
 					  NULL, &error);
 	g_object_unref (playlist);
 	g_free (name);
Index: sources/rb-playlist-source.h
===================================================================
--- sources/rb-playlist-source.h	(revision 5700)
+++ sources/rb-playlist-source.h	(working copy)
@@ -76,7 +76,7 @@
 
 void		rb_playlist_source_save_playlist(RBPlaylistSource *source,
 						 const char *uri,
-						 gboolean m3u_format);
+						 gint format);
 
 void		rb_playlist_source_save_to_xml	(RBPlaylistSource *source,
 						 xmlNodePtr parent_node);
Index: shell/rb-playlist-manager.c
===================================================================
--- shell/rb-playlist-manager.c	(revision 5700)
+++ shell/rb-playlist-manager.c	(working copy)
@@ -1331,10 +1331,12 @@
   const RBPlaylistExportType type;
 } RBPlaylistExportFilter;
 
+static const char *xspf_extensions [] = {"xspf", NULL};
 static const char *m3u_extensions [] = {"m3u", NULL};
 static const char *pls_extensions [] = {"pls", NULL};
 
 static RBPlaylistExportFilter playlist_export_formats[] = {
+	{N_("XML Shareable Playlist Format"), xspf_extensions, RB_PLAYLIST_EXPORT_TYPE_XSPF},
 	{N_("MPEG Version 3.0 URL"), m3u_extensions, RB_PLAYLIST_EXPORT_TYPE_M3U},
 	{N_("Shoutcast playlist"), pls_extensions, RB_PLAYLIST_EXPORT_TYPE_PLS},
 };
@@ -1384,7 +1386,7 @@
 			rb_error_dialog (NULL, _("Couldn't save playlist"), _("Unsupported file extension given."));
 	} else {
 		rb_playlist_source_save_playlist (RB_PLAYLIST_SOURCE (mgr->priv->selected_source),
-						  file, (export_type == RB_PLAYLIST_EXPORT_TYPE_M3U));
+						  file, export_type);
 		gtk_widget_destroy (GTK_WIDGET (dialog));
 	}
 
@@ -1806,7 +1808,7 @@
 rb_playlist_manager_export_playlist (RBPlaylistManager *mgr,
 				     const gchar *playlist,
 				     const gchar *uri,
-				     gboolean m3u_format,
+				     gint format,
 				     GError **error)
 {
 	RBSource *source = _get_playlist_by_name (mgr, playlist);
@@ -1821,6 +1823,6 @@
 
 	rb_playlist_source_save_playlist (RB_PLAYLIST_SOURCE (source),
 					  uri,
-					  m3u_format);
+					  format);
 	return TRUE;
 }
Index: shell/rb-playlist-manager.h
===================================================================
--- shell/rb-playlist-manager.h	(revision 5700)
+++ shell/rb-playlist-manager.h	(working copy)
@@ -77,6 +77,7 @@
 typedef enum
 {
 	RB_PLAYLIST_EXPORT_TYPE_UNKNOWN,
+	RB_PLAYLIST_EXPORT_TYPE_XSPF,
 	RB_PLAYLIST_EXPORT_TYPE_M3U,
 	RB_PLAYLIST_EXPORT_TYPE_PLS,
 } RBPlaylistExportType;
@@ -125,7 +126,7 @@
 gboolean		rb_playlist_manager_export_playlist (RBPlaylistManager *mgr,
 							     const gchar *name,
 							     const gchar *uri,
-							     gboolean m3u_format,
+							     gint format,
 							     GError **error);
 
 G_END_DECLS
Comment 8 Jonathan Matthew 2008-11-08 08:32:14 UTC
I've committed most of this.  The main bit I excluded was the change to rb_playlist_manager_export_playlist, since that's part of the dbus interface and I'm not sure we want to break that.

The XSPF files we save aren't very interesting - they don't even have title information - so I guess I'll leave this open for that.
Comment 9 Bastien Nocera 2010-01-08 17:36:13 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=551393#c1 for the details of which metadata you could now add to XSPF when saving playlists (and which fields of the iters you need to inform).
Comment 10 GNOME Infrastructure Team 2018-05-24 12:03:33 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/rhythmbox/issues/270.