diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-06-04 00:31:01 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-06-04 00:31:01 +0100 |
commit | 7d2ce9aeac8ddd4ba3116fe38f502491d9ab4f80 (patch) | |
tree | c951ed40cfeecc0bfdecd759c0137114db8298d6 | |
parent | 7a2a486ba0f90fef07c0a758ebdf36acc253e1a9 (diff) |
Scan media entities as well, not just url entities. This should expand more
t.co URLs.
-rw-r--r-- | protocols/twitter/twitter_lib.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index bfcebd2b..01e8f538 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; + } } } |