summaryrefslogtreecommitdiffstats
path: root/kachelmann
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2011-08-07 17:33:14 +0200
committermakefu <github@syntax-fehler.de>2011-08-07 17:33:14 +0200
commit4a540ca80b6288d8f2ae9af13c4efde95b0a01e7 (patch)
tree24c0d258384f8487fa3f274c2ba7d771d4ecca2b /kachelmann
parentc282ed39d512e92a26370497792362159b23dae5 (diff)
parentd29aa166348fd3fdb309f4038ad9216652334bb4 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'kachelmann')
-rw-r--r--kachelmann/.conditions.swpbin0 -> 12288 bytes
-rw-r--r--kachelmann/.gitignore2
-rw-r--r--kachelmann/changes31
-rwxr-xr-xkachelmann/conditions7
-rwxr-xr-xkachelmann/conditions.pl7
5 files changed, 36 insertions, 11 deletions
diff --git a/kachelmann/.conditions.swp b/kachelmann/.conditions.swp
new file mode 100644
index 00000000..a7b2f79d
--- /dev/null
+++ b/kachelmann/.conditions.swp
Binary files differ
diff --git a/kachelmann/.gitignore b/kachelmann/.gitignore
new file mode 100644
index 00000000..050dfb2e
--- /dev/null
+++ b/kachelmann/.gitignore
@@ -0,0 +1,2 @@
+conditions.pl
+.*.swp
diff --git a/kachelmann/changes b/kachelmann/changes
new file mode 100644
index 00000000..dfd22b64
--- /dev/null
+++ b/kachelmann/changes
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+use XML::Simple;
+my $xml = new XML::Simple;
+my $data_new = undef;
+my $data_old = undef;
+
+
+&startup;
+while (true) {
+ if($status_new != $status_old){
+ system("espeak -v de \"Das Wetter hat sich von $status_old in $status_new verändert\"");
+ }
+ sleep(300);
+ &get_status;
+}
+
+
+# The startup sub is used to get the first weather state. it should only be used on startup. sorry.
+sub startup(){
+ system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
+ $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml");
+ $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data};
+}
+
+# The get_status sub moves the current data to $data_old and then gets a new one from Googles API
+sub get_status(){
+ system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
+ $data_old = $data_new;
+ $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml");
+ $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data};
+}
diff --git a/kachelmann/conditions b/kachelmann/conditions
index 1a798e42..ea4ba5ca 100755
--- a/kachelmann/conditions
+++ b/kachelmann/conditions
@@ -1,7 +1,6 @@
#!/usr/bin/perl
use XML::Simple;
-system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
+my $result = `w3m -dump "http://www.google.com/ig/api?weather=70327-stuttgart&hl=de"`;
my $xml = new XML::Simple;
-my $data = $xml->XMLin("/tmp/kachelmann/weather.xml");
-my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n";
-system("espeak -v de \"$sentence\"");
+my $data = $xml->XMLin($result);
+print ("Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n");
diff --git a/kachelmann/conditions.pl b/kachelmann/conditions.pl
deleted file mode 100755
index 6d8b5541..00000000
--- a/kachelmann/conditions.pl
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/perl
-use XML::Simple;
-system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml");
-my $xml = new XML::Simple;
-my $data = $xml->XMLin("/tmp/kachelmann/weather.xml");
-my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n";
-system("espeak \"$sentence\"");