summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmike <michael.blumenkrantz@gmail.com>2014-12-21 18:40:33 -0500
committerzmike <michael.blumenkrantz@gmail.com>2014-12-21 18:40:33 -0500
commit157fa1321ff479dede0162e0fb845549d729013e (patch)
treef523381cd2bc38bf5a898e2ea5f497e6814a51dc
parentf3c569f753cb591b78688e8ac55cd652275ac7d3 (diff)
add support for Special:Export xml pages with faster parsing
thx thomasg
-rw-r--r--excetra.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/excetra.c b/excetra.c
index 15fe805..4edd120 100644
--- a/excetra.c
+++ b/excetra.c
@@ -69,6 +69,8 @@ lyricwiki_parse_lyric(Eina_Strbuf *buf)
69 return NULL; 69 return NULL;
70 } 70 }
71 s = eina_strbuf_string_get(buf); 71 s = eina_strbuf_string_get(buf);
72#ifdef OLD_FETCH
73 if (size > 40000) s += 40000;
72 lyric_start = strstr(s, "phone_right.gif"); 74 lyric_start = strstr(s, "phone_right.gif");
73 if (lyric_start) 75 if (lyric_start)
74 { 76 {
@@ -87,14 +89,25 @@ lyricwiki_parse_lyric(Eina_Strbuf *buf)
87 lyric_start += sizeof("</script>") - 1; 89 lyric_start += sizeof("</script>") - 1;
88 } 90 }
89 lyric_end = strstr(lyric_start, "<!--"); 91 lyric_end = strstr(lyric_start, "<!--");
92#else
93 if (size > 2000) s += 2000;
94 lyric_start = strstr(s, "&lt;lyrics&gt;\n");
95 if (!lyric_start) goto error;
96 lyric_start += sizeof("&lt;lyrics&gt;\n") - 1; //+\n
97 lyric_end = strstr(lyric_start, "\n&lt;/lyrics&gt;");
98#endif
90 if (!lyric_end) goto error; 99 if (!lyric_end) goto error;
91 lyric_end[0] = 0; 100 lyric_end[0] = 0;
101#ifdef OLD_FETCH
92 while (lyric_end[-1] == '\n') 102 while (lyric_end[-1] == '\n')
93 { 103 {
94 lyric_end[-1] = 0; 104 lyric_end[-1] = 0;
95 lyric_end--; 105 lyric_end--;
96 } 106 }
97 return evas_textblock_text_markup_to_utf8(NULL, lyric_start); 107 return evas_textblock_text_markup_to_utf8(NULL, lyric_start);
108#else
109 return strdup(lyric_start);
110#endif
98error: 111error:
99 ERR("Parsing error!"); 112 ERR("Parsing error!");
100 return NULL; 113 return NULL;
@@ -120,6 +133,9 @@ lyricwiki_parse_stub(Excetra_Req *req)
120 azy_content_deserialize(content, net); 133 azy_content_deserialize(content, net);
121 if (azy_value_to_Lyricwiki_Lyric(azy_content_retval_get(content), &lwl)) 134 if (azy_value_to_Lyricwiki_Lyric(azy_content_retval_get(content), &lwl))
122 { 135 {
136 char buf[4096] = {0};
137 const char *p;
138
123 INF("STUB:"); 139 INF("STUB:");
124 Lyricwiki_Lyric_print(NULL, 0, lwl); 140 Lyricwiki_Lyric_print(NULL, 0, lwl);
125 ecore_con_url_free(req->url); 141 ecore_con_url_free(req->url);
@@ -130,7 +146,15 @@ lyricwiki_parse_stub(Excetra_Req *req)
130 excetra_req_free(req); 146 excetra_req_free(req);
131 return; 147 return;
132 } 148 }
149#ifdef OLD_FETCH
133 req->url = ecore_con_url_new(lwl->url); 150 req->url = ecore_con_url_new(lwl->url);
151#else
152 p = strrchr(lwl->url, '/');
153 memcpy(buf, lwl->url, p - lwl->url);
154 memcpy(buf + (p - lwl->url), "/Special:Export", sizeof("/Special:Export") - 1);
155 strncpy(buf + (p - lwl->url) + sizeof("/Special:Export") - 1, p, sizeof(buf) - ((p - lwl->url) + sizeof("/Special:Export") - 1));
156 req->url = ecore_con_url_new(buf);
157#endif
134 ecore_con_url_data_set(req->url, req); 158 ecore_con_url_data_set(req->url, req);
135 ecore_con_url_get(req->url); 159 ecore_con_url_get(req->url);
136 } 160 }
@@ -160,7 +184,11 @@ lyricwiki_complete(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Ur
160 184
161 tp = azy_util_transport_get(h); 185 tp = azy_util_transport_get(h);
162 if (tp == AZY_NET_TRANSPORT_JAVASCRIPT) break; 186 if (tp == AZY_NET_TRANSPORT_JAVASCRIPT) break;
187#ifdef OLD_FETCH
163 if (tp == AZY_NET_TRANSPORT_HTML) 188 if (tp == AZY_NET_TRANSPORT_HTML)
189#else
190 if (tp == AZY_NET_TRANSPORT_XML)
191#endif
164 { 192 {
165 stub = EINA_FALSE; 193 stub = EINA_FALSE;
166 break; 194 break;