diff options
author | infirit <[email protected]> | 2014-12-20 18:11:15 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2015-08-25 10:56:45 +0200 |
commit | 708d58fc336a6d45cbebdfeb5a49a8ec4fec5fc9 (patch) | |
tree | c9fb14b41915d75253ba75407563f63a88cd6cf9 | |
parent | 1c22c2b0b6a7232766a09a76e8f9fa1278a656b3 (diff) | |
download | libmateweather-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.c | 15 |
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); } |