[libgweather] Improve parsing from bom.gov.au forecasts
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] Improve parsing from bom.gov.au forecasts
- Date: Mon, 24 Oct 2011 14:09:37 +0000 (UTC)
commit 73829e640d2ebd7f926563145ca81702c17d0abb
Author: Vincent Untz <vuntz gnome org>
Date: Mon Oct 24 16:09:13 2011 +0200
Improve parsing from bom.gov.au forecasts
We can safely remove some non-interesting text.
libgweather/weather-bom.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/libgweather/weather-bom.c b/libgweather/weather-bom.c
index 7176d4f..e56ba14 100644
--- a/libgweather/weather-bom.c
+++ b/libgweather/weather-bom.c
@@ -30,6 +30,7 @@ static void
bom_finish (SoupSession *session, SoupMessage *msg, gpointer data)
{
WeatherInfo *info = (WeatherInfo *)data;
+ char *p, *rp;
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]