From 7409c0e7003306ef5b96234b666adcb2ed0452bf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 4 Jun 2012 00:31:01 +0100 Subject: [PATCH] Scan media entities as well, not just url entities. This should expand more t.co URLs. --- protocols/twitter/twitter_lib.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index bfcebd2..01e8f53 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -500,23 +500,30 @@ static xt_status twitter_xt_get_status(struct xt_node *node, struct twitter_xml_ } else { struct xt_node *urls, *url; - urls = xt_find_path(node, "entities/urls"); - for (url = urls ? urls->children : NULL; url; url = url->next) { - /* "short" is a reserved word. :-P */ - struct xt_node *kort = xt_find_node(url->children, "url"); - struct xt_node *disp = xt_find_node(url->children, "display_url"); - char *pos, *new; - - if (!kort || !kort->text || !disp || !disp->text || - !(pos = strstr(txs->text, kort->text))) + urls = xt_find_path(node, "entities"); + if (urls != NULL) + urls = urls->children; + for (; urls; urls = urls->next) { + if (strcmp(urls->name, "urls") != 0 && strcmp(urls->name, "media") != 0) continue; - *pos = '\0'; - new = g_strdup_printf("%s%s <%s>%s", txs->text, kort->text, - disp->text, pos + strlen(kort->text)); - - g_free(txs->text); - txs->text = new; + for (url = urls ? urls->children : NULL; url; url = url->next) { + /* "short" is a reserved word. :-P */ + struct xt_node *kort = xt_find_node(url->children, "url"); + struct xt_node *disp = xt_find_node(url->children, "display_url"); + char *pos, *new; + + if (!kort || !kort->text || !disp || !disp->text || + !(pos = strstr(txs->text, kort->text))) + continue; + + *pos = '\0'; + new = g_strdup_printf("%s%s <%s>%s", txs->text, kort->text, + disp->text, pos + strlen(kort->text)); + + g_free(txs->text); + txs->text = new; + } } } -- 2.11.4.GIT