Ticket #2661: patch
| File patch, 3.4 KB (added by , 19 years ago) |
|---|
-
/usr/share/mythtv/mythweather/scripts/animaps.pl
old new 1 1 #!/usr/bin/perl -w 2 # 3 # animaps.pl 4 # 5 # This script grabs the source image(s) and provides an animated version of the 6 # still images back to Myth. 7 # 8 # This script uses the maps.xml file as the list of available sources. Please 9 # take a look at that file for examples of how to format particular sources. 10 # 11 ################################################################################ 2 12 use strict; 3 13 use Getopt::Std; 4 14 use LWP::Simple; … … 7 17 use Data::Dumper; 8 18 our ($opt_v, $opt_t, $opt_T, $opt_l, $opt_u, $opt_d); 9 19 10 my $name = 'Animated-Map-Download'; 11 my $version = 0.1; 20 ### 21 # 22 # These defines are required by the MythWeather modules. What is defined here 23 # will be displayed in the GUI. 24 # 25 ### 26 my $name = 'Animated_Regional_Map'; 27 my $version = 0.21; 12 28 my $author = 'Lucien Dunning'; 13 29 my $email = 'ldunning@gmail.com'; 30 31 ## 32 # Some defaults. 33 ## 14 34 my $updateTimeout = 10*60; 15 35 my $retrieveTimeout = 30; 16 36 my @types = ('amdesc', 'updatetime', 'animatedimage'); 37 ## 38 # Our xml file is local to the directory that the script is run in. 39 ## 17 40 my $dir = "./"; 18 41 42 ## 43 # Get and parse the command line arguments 44 ## 19 45 getopts('Tvtlu:d:'); 20 46 21 47 if (defined $opt_v) { … … 50 76 die "Invalid usage"; 51 77 } 52 78 53 #should only get one location result since its by url, assuming things is fun :) 79 ## 80 # If we got to here, then we have all of the right arguments. We should 81 # only get one location via the command line options. 82 # 83 # First, we need to search through the XML file for the specified location 84 # and get all of the necessary attributes of that location. 85 ## 54 86 MapSearch::AddAniSearch($loc); 55 87 my $results = MapSearch::doSearch(); 56 88 my $base = $results->[0]->{animation}; … … 59 91 my $file = $desc; 60 92 $file =~ s/[^a-zA-Z0-9]//g; 61 93 my $path = "$dir/$file-"; 62 my $i = 0; 94 my $image_count = 0; 95 my $i=0; 63 96 foreach my $image (sort @{$results->[0]->{images}}) { 64 getstore("$base/$image", $path . "$i"); 65 ++$i; 97 ++$image_count; 98 } 99 ## 100 # Because Myth does not support animated GIFs, we have to do a little 101 # hacking if the source is an animated GIF. 102 # 103 # Hack to check if there is only one image listed as the source for the 104 # animated images. If it is, then we assume it is an animated GIF (it better 105 # be, darn it!) and we split it in to its individual frames. 106 ## 107 if (($image_count == 1) && (@{$results->[0]->{images}}[0] =~ /.gif$/)) 108 { 109 # Get the Animated GIF 110 getstore("$base/" . @{$results->[0]->{images}}[0], $path . "anim.gif"); 111 # Split it in to its individual parts 112 system("/usr/bin/convert +adjoin -coalesce " . $path . "anim.gif " . $path . "%01d"); 113 # Now, count up all of the individual pieces. 114 system ("echo \"ls -l $path\" > /tmp/test.log"); 115 open (LS, "ls -l $path\* |"); 116 while (<LS>) 117 { 118 ++$i if ((/$path/) && !(/anim.gif/)); 119 } 120 close (LS); 121 } 122 else 123 { 124 foreach my $image (sort @{$results->[0]->{images}}) { 125 getstore("$base/$image", $path . "$i"); 126 ++$i; 127 } 66 128 } 67 129 # assume all the same size, so just check first 68 130 if (!$size) { … … 71 133 $size = "${x}x$y" if ($x && $y); 72 134 } 73 135 74 75 136 print "amdesc::$desc\n"; 76 137 printf "animatedimage::${path}%%1-$i%s\n", ($size && "-$size" || ''); 77 138 print "updatetime::Last Updated on " . UnixDate("now", "%b %d, %I:%M %p %Z") . "\n";
