Re: [Multi-valued V2 (grilo-plugins) 2/2] lastfm-albumart: Provide all available thumbnails




Please add support for all the thumbnail versions in the Youtube plugin too, right now I think only the first one is used.

Iago

On Tue, 1 Mar 2011 10:51:23 +0100, "Juan A. Suarez Romero" <jasuarez igalia com> wrote:
Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
 src/lastfm-albumart/grl-lastfm-albumart.c |   41
+++++++++++++++++++++++-----
 1 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/lastfm-albumart/grl-lastfm-albumart.c
b/src/lastfm-albumart/grl-lastfm-albumart.c
index 12cfb28..3c70148 100644
--- a/src/lastfm-albumart/grl-lastfm-albumart.c
+++ b/src/lastfm-albumart/grl-lastfm-albumart.c
@@ -41,7 +41,10 @@ GRL_LOG_DOMAIN_STATIC(lastfm_albumart_log_domain);
 /* -------- Last.FM API -------- */

 #define LASTFM_GET_ALBUM
"http://ws.audioscrobbler.com/1.0/album/%s/%s/info.xml";
-#define LASTFM_XML_COVER "/album/coverart/medium"
+
+#define LASTFM_XML_COVER_MEDIUM "/album/coverart/medium"
+#define LASTFM_XML_COVER_LARGE  "/album/coverart/large"
+#define LASTFM_XML_COVER_SMALL  "/album/coverart/small"

 /* ------- Pluging Info -------- */

@@ -145,7 +148,7 @@ grl_lastfm_albumart_source_finalize (GObject *object)
 /* ======================= Utilities ==================== */

 static gchar *
-xml_get_image (const gchar *xmldata)
+xml_get_image (const gchar *xmldata, const gchar *image_node)
 {
   xmlDocPtr doc;
   xmlXPathContextPtr xpath_ctx;
@@ -164,8 +167,7 @@ xml_get_image (const gchar *xmldata)
     return NULL;
   }

-  xpath_res = xmlXPathEvalExpression ((xmlChar *) LASTFM_XML_COVER,
-                                      xpath_ctx);
+ xpath_res = xmlXPathEvalExpression ((xmlChar *) image_node, xpath_ctx);
   if (!xpath_res) {
     xmlXPathFreeContext (xpath_ctx);
     xmlFreeDoc (doc);
@@ -194,6 +196,7 @@ read_done_cb (GObject *source_object,
     (GrlMetadataSourceResolveSpec *) user_data;
   GError *error = NULL;
   GError *wc_error = NULL;
+  GrlProperty *proprel;
   gchar *content = NULL;
   gchar *image = NULL;

@@ -213,11 +216,33 @@ read_done_cb (GObject *source_object,
     return;
   }

-  image = xml_get_image (content);
+  image = xml_get_image (content, LASTFM_XML_COVER_MEDIUM);
+  if (image) {
+    proprel = grl_property_new_for_key (GRL_METADATA_KEY_THUMBNAIL);

I guess this is related with a previous comment of mine... what is the purpose of passing a key to this constructor?

+    grl_property_set_string (proprel,
+                             GRL_METADATA_KEY_THUMBNAIL,
+                             image);
+    grl_data_add_property (GRL_DATA (rs->media), proprel);
+    g_free (image);
+  }

Iago


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