aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-09-27 14:39:11 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-09-27 14:39:11 +0100
commit857db46c9652b8f1025a141e31d9760c8d249435 (patch)
tree6c3cb7b78868b83bff2881a7e817372226b2a622
parentrage thumb - limit max parallel thumb fetch to 4 at a time (diff)
downloadrage-857db46c9652b8f1025a141e31d9760c8d249435.tar.gz
rage albumart - delay img fetch as it seems no response if too fast
-rw-r--r--src/bin/albumart.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/bin/albumart.c b/src/bin/albumart.c
index abdc4da..3093d1b 100644
--- a/src/bin/albumart.c
+++ b/src/bin/albumart.c
@@ -81,6 +81,7 @@ _fetch(Eina_Strbuf *sb)
qs = eina_strbuf_string_get(sb);
if (!qs) return NULL;
+// printf("GET %s\n", qs);
f = ecore_con_url_new(qs);
if (!f) return NULL;
ecore_con_url_additional_header_add
@@ -96,6 +97,7 @@ _cb_http_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
Ecore_Con_Event_Url_Data *ev = event;
if (ev->url_con != fetch) return EINA_TRUE;
+// printf("HTTP DATA %i (fetch image? %i)\n", (int)ev->size, fetch_image);
if (fetch_image) fwrite(ev->data, ev->size, 1, fout);
else if (sb_result)
eina_strbuf_append_length(sb_result, (char *)ev->data, (size_t)ev->size);
@@ -103,6 +105,15 @@ _cb_http_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
}
static Eina_Bool
+_delay_fetch(void *data)
+{
+ Eina_Strbuf *sb = data;
+ fetch = _fetch(sb);
+ eina_strbuf_free(sb);
+ return EINA_FALSE;
+}
+
+static Eina_Bool
_cb_http_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Con_Event_Url_Complete *ev = event;
@@ -142,6 +153,7 @@ _cb_http_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
if (pe)
{
eina_strbuf_append_length(sb, p, pe - p);
+ printf("FOUND IMG\n");
ok = EINA_TRUE;
}
}
@@ -155,6 +167,7 @@ _cb_http_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
if (pe)
{
eina_strbuf_append_length(sb, p, pe - p);
+ printf("FOUND IMG2\n");
ok = EINA_TRUE;
}
}
@@ -176,7 +189,10 @@ _cb_http_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
if (fout)
{
fetch_image = EINA_TRUE;
- fetch = _fetch(sb);
+// delay this - it seems google doesn;'t like to respond if we ask too fast
+// fetch = _fetch(sb);
+ ecore_timer_add(1.5, _delay_fetch, sb);
+ sb = NULL;
free(fetchpath);
free(fetchpath2);
fetchpath = strdup(path);
@@ -185,7 +201,7 @@ _cb_http_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
free(path);
}
}
- eina_strbuf_free(sb);
+ if (sb) eina_strbuf_free(sb);
}
eina_strbuf_free(sb_result);
sb_result = NULL;