summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2011-01-11 05:02:55 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2011-01-11 05:49:31 (GMT)
commit6574b9cb51d22b4b717b5c84281c927fe7d9b532 (patch)
tree6bdc33ea7ace3b3dc8dd54f7afda75c0d4f56fec
parent09800d6abc5be917f6837bae1639ac1386db4a3a (diff)
Fix Environment Canada animated maps.
As the support for the "pile of images" animation was removed to simplify the mythweather code, this script stopped working. Additionally, it was not returning any copyright data. As the requirement for Image::Magick has already been added for some of the mythnetvision scripts, there's little reason not to use it in mythweather. To fix this animation, we are now reading in each downloaded image in turn with Image::Magick, and making an animated GIF to pass to mythweather. Fixes #9467
-rwxr-xr-xmythplugins/mythweather/mythweather/scripts/ca_envcan/envcan_animaps.pl40
1 files changed, 25 insertions, 15 deletions
diff --git a/mythplugins/mythweather/mythweather/scripts/ca_envcan/envcan_animaps.pl b/mythplugins/mythweather/mythweather/scripts/ca_envcan/envcan_animaps.pl
index 373d7aa..8b89bf0 100755
--- a/mythplugins/mythweather/mythweather/scripts/ca_envcan/envcan_animaps.pl
+++ b/mythplugins/mythweather/mythweather/scripts/ca_envcan/envcan_animaps.pl
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+# vim:ts=4:sw=4:ai:et:si:sts=4
#
# Animated satellite map grabber for Environment Canada.
#
@@ -13,6 +14,7 @@ use strict;
use warnings;
use English;
+use File::Path;
use File::Basename;
use Cwd 'abs_path';
use lib dirname(abs_path($0 or $PROGRAM_NAME)),
@@ -23,17 +25,18 @@ use Getopt::Std;
use LWP::Simple;
use Date::Manip;
use ENVCANMapSearch;
+use Image::Magick;
our ($opt_v, $opt_t, $opt_T, $opt_l, $opt_u, $opt_d);
my $name = 'ENVCAN-Animated-Map';
-my $version = 0.3;
+my $version = 0.4;
my $author = 'Joe Ripley';
my $email = 'vitaminjoe@gmail.com';
my $updateTimeout = 10*60;
my $retrieveTimeout = 30;
-my @types = ('amdesc', 'updatetime', 'animatedimage');
-my $dir = "./";
+my @types = ('amdesc', 'updatetime', 'animatedimage', 'copyright');
+my $dir = "/tmp/envcan";
getopts('Tvtlu:d:');
@@ -66,6 +69,10 @@ if (defined $opt_d) {
$dir = $opt_d;
}
+if (!-d $dir) {
+ mkpath( $dir, {mode => 0755} );
+}
+
my $loc = shift;
if (!defined $loc || $loc eq "") {
@@ -97,24 +104,27 @@ foreach my $line (split(/\n/, $response)) {
# Download map files, if necessary (maps are stale after 15 minutes)
my $i = 0;
+my $outimage = Image::Magick->new;
foreach my $image (@image_list) {
my $getImage = 1;
- if (-f $path . $i) {
+ if (-f "$path$i" ) {
my @stats = stat(_);
- if ($stats[9] > (time - 900)) { $i++; next; }
+ if ($stats[9] > (time - 900)) {
+ $outimage->Read( "$path$i" );
+ $i++;
+ next;
+ }
}
- getstore($base_url . $image, $path . $i);
+ getstore($base_url . $image, "$path$i");
+ $outimage->Read( "$path$i" );
$i++;
}
-# Determine image size
-if (!$size) {
- use Image::Size;
- my ($x, $y) = imgsize("${path}0");
- $size = "${x}x$y" if ($x && $y);
-}
+$outimage->Write( filename => "$dir/$file.gif", delay => 75 );
-print "amdesc::$desc\n";
-printf "animatedimage::${path}%%1-$i%s\n", ($size && "-$size" || '');
-print "updatetime::Last Updated on " . UnixDate("now", "%b %d, %I:%M %p %Z") . "\n";
+print "amdesc::$desc\n";
+print "animatedimage::$dir/$file.gif\n";
+print "updatetime::Last Updated on " .
+ UnixDate("now", "%b %d, %I:%M %p %Z") . "\n";
+print "copyright::Environment Canada\n";