[grilo-plugins] flickr: Use largest image if original can not be downloaded
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] flickr: Use largest image if original can not be downloaded
- Date: Thu, 15 Jul 2010 08:22:46 +0000 (UTC)
commit 86669a4f2fa2ef6a4e85fa715aecc79b8323084b
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed Jul 7 12:22:09 2010 +0200
flickr: Use largest image if original can not be downloaded
Original photos from non-subscribers can not be accessed. So in this case
return the largest image available.
src/flickr/gflickr.c | 31 +++++++++++++++++++++++++++++++
src/flickr/gflickr.h | 3 +++
src/flickr/grl-flickr.c | 3 +++
3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/flickr/gflickr.c b/src/flickr/gflickr.c
index e50e39f..f5e473e 100644
--- a/src/flickr/gflickr.c
+++ b/src/flickr/gflickr.c
@@ -16,6 +16,9 @@
#define FLICKR_PHOTO_THUMB_URL \
"http://farm%s.static.flickr.com/%s/%s_%s_t.jpg"
+#define FLICKR_PHOTO_LARGEST_URL \
+ "http://farm%s.static.flickr.com/%s/%s_%s_b.jpg"
+
#define FLICKR_ENDPOINT "http://api.flickr.com/services/rest/?"
#define FLICKR_AUTHPOINT "http://flickr.com/services/auth/?"
@@ -769,6 +772,34 @@ g_flickr_photo_url_thumbnail (GFlickr *f, GHashTable *photo)
}
}
+gchar *
+g_flickr_photo_url_largest (GFlickr *f, GHashTable *photo)
+{
+ gchar *farm_id;
+ gchar *secret;
+ gchar *photo_id;
+ gchar *server_id;
+
+ if (!photo) {
+ return NULL;
+ }
+
+ farm_id = g_hash_table_lookup (photo, "photo_farm");
+ secret = g_hash_table_lookup (photo, "photo_secret");
+ photo_id = g_hash_table_lookup (photo, "photo_id");
+ server_id = g_hash_table_lookup (photo, "photo_server");
+
+ if (!farm_id || !secret || !photo_id || !server_id) {
+ return NULL;
+ } else {
+ return g_strdup_printf (FLICKR_PHOTO_LARGEST_URL,
+ farm_id,
+ server_id,
+ photo_id,
+ secret);
+ }
+}
+
void
g_flickr_tags_getHotList (GFlickr *f,
gint count,
diff --git a/src/flickr/gflickr.h b/src/flickr/gflickr.h
index b0024cd..be7dfa7 100644
--- a/src/flickr/gflickr.h
+++ b/src/flickr/gflickr.h
@@ -105,6 +105,9 @@ g_flickr_photo_url_original (GFlickr *f, GHashTable *photo);
gchar *
g_flickr_photo_url_thumbnail (GFlickr *f, GHashTable *photo);
+gchar *
+g_flickr_photo_url_largest (GFlickr *f, GHashTable *photo);
+
void
g_flickr_tags_getHotList (GFlickr *f,
gint count,
diff --git a/src/flickr/grl-flickr.c b/src/flickr/grl-flickr.c
index b13ac91..4433ca4 100644
--- a/src/flickr/grl-flickr.c
+++ b/src/flickr/grl-flickr.c
@@ -301,6 +301,9 @@ update_media (GrlMedia *media, GHashTable *photo)
url = g_strdup (g_hash_table_lookup (photo, "photo_url_o"));
if (!url) {
url = g_flickr_photo_url_original (NULL, photo);
+ if (!url) {
+ url = g_flickr_photo_url_largest (NULL, photo);
+ }
}
if (author) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]