From 708d58fc336a6d45cbebdfeb5a49a8ec4fec5fc9 Mon Sep 17 00:00:00 2001 From: infirit Date: Sat, 20 Dec 2014 18:11:15 +0100 Subject: Improve parsing from bom.gov.au forecasts We can safely remove some non-interesting text Taken from libgweather commit: 73829e640d2ebd7f926563145ca81702c17d0abb From: Vincent Untz --- libmateweather/weather-bom.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libmateweather/weather-bom.c b/libmateweather/weather-bom.c index aab6c8b..47b2d0b 100644 --- a/libmateweather/weather-bom.c +++ b/libmateweather/weather-bom.c @@ -29,6 +29,7 @@ static void bom_finish (SoupSession *session, SoupMessage *msg, gpointer data) { + char *p, *rp; WeatherInfo *info = (WeatherInfo *)data; g_return_if_fail (info != NULL); @@ -40,7 +41,19 @@ bom_finish (SoupSession *session, SoupMessage *msg, gpointer data) return; } - info->forecast = g_strdup (msg->response_body->data); + p = strstr (msg->response_body->data, "Forecast for the rest"); + if (p != NULL) { + rp = strstr (p, "The next routine forecast will be issued"); + if (rp == NULL) + info->forecast = g_strdup (p); + else + info->forecast = g_strndup (p, rp - p); + } + + if (info->forecast == NULL) + info->forecast = g_strdup (msg->response_body->data); + + g_print ("%s\n", info->forecast); request_done (info, TRUE); } -- cgit v1.2.1