Exemple #1
0
static void
add_image (GrlTmdbSource *self,
           GrlMedia      *media,
           GrlKeyID       detail_key,
           const char    *image_path)
{
  SoupURI *uri;
  GrlRelatedKeys *related_keys;
  char *str;
  int i, l;

  str = g_strconcat ("original", image_path, NULL);
  uri = soup_uri_new_with_base (self->priv->image_base_uri, str);
  g_free (str);

  str = soup_uri_to_string (uri, FALSE);

  l = grl_data_length (GRL_DATA (media), detail_key);

  for (i = 0; i < l; ++i) {
    related_keys = grl_data_get_related_keys (GRL_DATA (media), detail_key, i);
    if (g_strcmp0 (grl_related_keys_get_string (related_keys, detail_key), str) == 0)
      break;
  }

  if (i == l) {
    grl_data_add_string (GRL_DATA (media), detail_key, str);
  }

  g_free (str);
  soup_uri_free (uri);
}
static void
set_avatar (GrlData *data,
            GrlKeyID key)
{
  gint length, i;
  GrlRelatedKeys *relkeys;
  gchar *avatar_url;

  length = grl_data_length (data, key);

  for (i = 0; i < length; i++) {
    relkeys = grl_data_get_related_keys (data, key, i);
    avatar_url = get_avatar (grl_related_keys_get_string (relkeys, key));
    if (avatar_url) {
      grl_related_keys_set_string (relkeys, key, avatar_url);
      g_free (avatar_url);
    }
  }
}