summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-20 18:11:15 +0100
committerinfirit <[email protected]>2015-08-25 10:56:45 +0200
commit708d58fc336a6d45cbebdfeb5a49a8ec4fec5fc9 (patch)
treec9fb14b41915d75253ba75407563f63a88cd6cf9
parent1c22c2b0b6a7232766a09a76e8f9fa1278a656b3 (diff)
downloadlibmateweather-708d58fc336a6d45cbebdfeb5a49a8ec4fec5fc9.tar.bz2
libmateweather-708d58fc336a6d45cbebdfeb5a49a8ec4fec5fc9.tar.xz
Improve parsing from bom.gov.au forecasts
We can safely remove some non-interesting text Taken from libgweather commit: 73829e640d2ebd7f926563145ca81702c17d0abb From: Vincent Untz <[email protected]>
-rw-r--r--libmateweather/weather-bom.c15
1 files changed, 14 insertions, 1 deletions
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);
}