Posts Tagged ‘perl’

AccuWeather.pl Cacti Fix

Thursday, September 6th, 2007

I got bored today and decided that I wanted to monitor weather in different locations with my Cacti setup. I obtained a copy of the AccuWeather perl script and also the XML file for Cacti, loaded it up and what do you know… It wasn’t graphing the Temp or the RealFeel®. With a little help from my friend Wezzul I was able to get it graphing correctly. I present to you the fixed perl script.

#!/usr/bin/perl
use warnings;
use strict;

use LWP::Simple;

my $httpaddr = "http://wwwa.accuweather.com/forecast-current-conditions.asp?partner=forecastfox&myadc=0&traveler=1&zipcode=" . $ARGV[0] . "&metric=0";

my %data;
my $content = LWP::Simple::get($httpaddr) or die "Couldn’t get it!";
$content =~ s/\ |\n//g;

# regex in html source order
if ($content =~ /(-?\d+)°/g) { $data{Temp} = $1; }
if ($content =~ /RealFeel&reg;< \/a>:< \/div>\s+<div style=".*" >(-?\d+)&deg;F< \/div>/g)  { $data{RealFeel} = $1; }
if ($content =~ /(\d+)%/g)  { $data{Humidity} = $1; }
if ($content =~ /(\d+)%/g) { $data{CloudCover} = $1; }
if ($content =~ /(\d+) mi/g) { $data{Visibility} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{MaxTemp} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{Dewpoint} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{MinTemp} = $1; }
if ($content =~ /(\d+) ft/g) { $data{Ceiling} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{Departure} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{ApparentTemp} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{HighPast6hrs} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{WindChill} = $1; }
if ($content =~ /(-?\d+)&deg;/g) { $data{LowPast6hrs} = $1; }
if ($content =~ /(\d+) mph/g) { $data{WindSpeed} = $1; }
if ($content =~ /(\d+) in/g) { $data{PrecipPast3hrs} = $1; }
if ($content =~ /(\d+) in/g) { $data{PrecipPast6hrs} = $1; }
if ($content =~ /(\d+) mph/g) { $data{WindGusts} = $1; }
if ($content =~ /(\d+) in/g) { $data{PrecipPast24hrs} = $1; }
if ($content =~ /(-?\d+\.\d+)&quot;/g) { $data{Pressure} = $1; }
if ($content =~ /(\d+) in/g) { $data{SnowOnGround} = $1; }

for (keys %data) {
  printf "%s:%s ", $_, $data{$_};
}
print "\n"
</div>

Channel Icons in MythTV on Ubuntu 6.10

Tuesday, April 3rd, 2007

If you want the channel icons on your MythWeb and MythTV you can use the following information to do so. I dont know why this is not included in MythTV .20 but you can grab it via SVN

(more…)