Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 212062c44d5576e5bf15db2d29b162f176ca7c53 1 parent 3128c78
@Beirdo Beirdo authored
View
40 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 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 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 @@
$dir = $opt_d;
}
+if (!-d $dir) {
+ mkpath( $dir, {mode => 0755} );
+}
+
my $loc = shift;
if (!defined $loc || $loc eq "") {
@@ -97,24 +104,27 @@
# 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";
Please sign in to comment.
Something went wrong with that request. Please try again.