totem-pl-parser r57 - in trunk: . plparse



Author: hadess
Date: Sun Feb 24 14:45:37 2008
New Revision: 57
URL: http://svn.gnome.org/viewvc/totem-pl-parser?rev=57&view=rev

Log:
2008-02-24  Bastien Nocera  <hadess hadess net>

	* plparse/totem-pl-parser-xspf.c (parse_xspf_track):
	* plparse/totem-pl-parser.c (totem_pl_parser_class_init):
	* plparse/totem-pl-parser.h: Add support for the some last.fm
	XSPF tags (lastfm:trackauth, duration in milliseconds, and
	download URLs as TOTEM_PL_PARSER_FIELD_ID,
	TOTEM_PL_PARSER_FIELD_DURATION_MS and
	TOTEM_PL_PARSER_FIELD_DOWNLOAD_URL respectively



Modified:
   trunk/ChangeLog
   trunk/plparse/totem-pl-parser-xspf.c
   trunk/plparse/totem-pl-parser.c
   trunk/plparse/totem-pl-parser.h

Modified: trunk/plparse/totem-pl-parser-xspf.c
==============================================================================
--- trunk/plparse/totem-pl-parser-xspf.c	(original)
+++ trunk/plparse/totem-pl-parser-xspf.c	Sun Feb 24 14:45:37 2008
@@ -182,6 +182,7 @@
 {
 	xmlNodePtr node;
 	xmlChar *title, *url, *image_url, *artist, *album, *duration, *moreinfo;
+	xmlChar *download_url, *id;
 	char *fullpath;
 	TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_ERROR;
 	
@@ -193,6 +194,8 @@
 	album = NULL;
 	duration = NULL;
 	moreinfo = NULL;
+	download_url = NULL;
+	id = NULL;
 
 	for (node = parent->children; node != NULL; node = node->next)
 	{
@@ -201,36 +204,33 @@
 
 		if (g_ascii_strcasecmp ((char *)node->name, "location") == 0)
 			url = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
-
-		if (g_ascii_strcasecmp ((char *)node->name, "title") == 0)
+		else if (g_ascii_strcasecmp ((char *)node->name, "title") == 0)
 			title = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
-
-		if (g_ascii_strcasecmp ((char *)node->name, "image") == 0)
+		else if (g_ascii_strcasecmp ((char *)node->name, "image") == 0)
 			image_url = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
-
 		/* Last.fm uses creator for the artist */
-		if (g_ascii_strcasecmp ((char *)node->name, "creator") == 0)
+		else if (g_ascii_strcasecmp ((char *)node->name, "creator") == 0)
 			artist = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
-
-		if (g_ascii_strcasecmp ((char *)node->name, "duration") == 0)
+		else if (g_ascii_strcasecmp ((char *)node->name, "duration") == 0)
 			duration = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
-
-		if (g_ascii_strcasecmp ((char *)node->name, "link") == 0) {
+		else if (g_ascii_strcasecmp ((char *)node->name, "link") == 0) {
 			xmlChar *rel;
 
 			rel = xmlGetProp (node, (const xmlChar *) "rel");
 			if (rel != NULL) {
 				if (g_ascii_strcasecmp ((char *) rel, "http://www.last.fm/trackpage";) == 0)
 					moreinfo = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
+				else if (g_ascii_strcasecmp ((char *) rel, "http://www.last.fm/freeTrackURL";) == 0)
+					download_url = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
 				xmlFree (rel);
 			} else {
 				/* If we don't have a rel="", then it's not a last.fm playlist */
 				moreinfo = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
 			}
-		}
-
-		if (g_ascii_strcasecmp ((char *)node->name, "album") == 0)
+		} else if (g_ascii_strcasecmp ((char *)node->name, "album") == 0)
 			album = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
+		else if (g_ascii_strcasecmp ((char *)node->name, "trackauth") == 0)
+			id = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
 	}
 
 	if (url == NULL) {
@@ -242,11 +242,13 @@
 	totem_pl_parser_add_url (parser,
 				 TOTEM_PL_PARSER_FIELD_URL, fullpath,
 				 TOTEM_PL_PARSER_FIELD_TITLE, title,
-				 TOTEM_PL_PARSER_FIELD_DURATION, duration,
+				 TOTEM_PL_PARSER_FIELD_DURATION_MS, duration,
 				 TOTEM_PL_PARSER_FIELD_IMAGE_URL, image_url,
 				 TOTEM_PL_PARSER_FIELD_AUTHOR, artist,
 				 TOTEM_PL_PARSER_FIELD_ALBUM, album,
 				 TOTEM_PL_PARSER_FIELD_MOREINFO, moreinfo,
+				 TOTEM_PL_PARSER_FIELD_DOWNLOAD_URL, download_url,
+				 TOTEM_PL_PARSER_FIELD_ID, id,
 				 NULL);
 
 	retval = TOTEM_PL_PARSER_RESULT_SUCCESS;

Modified: trunk/plparse/totem-pl-parser.c
==============================================================================
--- trunk/plparse/totem-pl-parser.c	(original)
+++ trunk/plparse/totem-pl-parser.c	Sun Feb 24 14:45:37 2008
@@ -431,7 +431,11 @@
 				     G_PARAM_READABLE & G_PARAM_WRITABLE);
 	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
 	pspec = g_param_spec_string ("duration", "duration",
-				     "String representing the duration of the entry, used for still images", NULL,
+				     "String representing the duration of the entry", NULL,
+				     G_PARAM_READABLE & G_PARAM_WRITABLE);
+	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
+	pspec = g_param_spec_string ("duration-ms", "duration-ms",
+				     "String representing the duration of the entry in milliseconds", NULL,
 				     G_PARAM_READABLE & G_PARAM_WRITABLE);
 	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
 	pspec = g_param_spec_string ("starttime", "starttime",
@@ -490,6 +494,14 @@
 				     "String representing the location of an image for a playlist", NULL,
 				     G_PARAM_READABLE & G_PARAM_WRITABLE);
 	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
+	pspec = g_param_spec_string ("download-url", "download-url",
+				     "String representing the location of a download URL", NULL,
+				     G_PARAM_READABLE & G_PARAM_WRITABLE);
+	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
+	pspec = g_param_spec_string ("id", "id",
+				     "String representing the identifier for an entry", NULL,
+				     G_PARAM_READABLE & G_PARAM_WRITABLE);
+	g_param_spec_pool_insert (totem_pl_parser_pspec_pool, pspec, TOTEM_TYPE_PL_PARSER);
 }
 
 static void

Modified: trunk/plparse/totem-pl-parser.h
==============================================================================
--- trunk/plparse/totem-pl-parser.h	(original)
+++ trunk/plparse/totem-pl-parser.h	Sun Feb 24 14:45:37 2008
@@ -125,6 +125,14 @@
  **/
 #define TOTEM_PL_PARSER_FIELD_DURATION		"duration"
 /**
+ * TOTEM_PL_PARSER_FIELD_DURATION_MS:
+ *
+ * Metadata field for an entry's playback duration, in milliseconds. It's only used when an entry's
+ * duration is available in that format, so one would get either the %TOTEM_PL_PARSER_FIELD_DURATION
+ * or %TOTEM_PL_PARSER_FIELD_DURATION_MS as metadata.
+ **/
+#define TOTEM_PL_PARSER_FIELD_DURATION_MS	"duration-ms"
+/**
  * TOTEM_PL_PARSER_FIELD_STARTTIME:
  *
  * Metadata field for an entry's playback start time, which should be parsed using totem_pl_parser_parse_duration().
@@ -209,6 +217,20 @@
  **/
 #define TOTEM_PL_PARSER_FIELD_IMAGE_URL		"image-url"
 /**
+ * TOTEM_PL_PARSER_FIELD_DOWNLOAD_URL:
+ *
+ * Metadata field for an entry's download URL. Only used if an alternate download
+ * location is available for the entry.
+ **/
+#define TOTEM_PL_PARSER_FIELD_DOWNLOAD_URL	"download-url"
+/**
+ * TOTEM_PL_PARSER_FIELD_ID:
+ *
+ * Metadata field for an entry's identifier. Its use is dependent on the format
+ * of the playlist parsed, and its origin.
+ **/
+#define TOTEM_PL_PARSER_FIELD_ID		"id"
+/**
  * TOTEM_PL_PARSER_FIELD_IS_PLAYLIST:
  *
  * Metadata field used to tell the calling code that the parsing of a playlist



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]