Changeset 415
- Timestamp:
- 2007-03-13 17:28:33 (2 years ago)
- Files:
-
- trunk/webcap/update.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/webcap/update.pl
r294 r415 2 2 3 3 use strict; 4 use warnings; 4 5 5 6 use DBI; 7 use LWP::UserAgent; 8 use URI::Escape; 6 9 7 if( -e "/tmp/webcap.lock" ) 8 { 9 die "Looks like an existing thumbshot update is already running"; 10 } 10 my $ua = LWP::UserAgent->new; 11 11 12 12 my $opt_url = shift; … … 18 18 my $dbh = DBI->connect("dbi:mysql:database=iar","iar","") or die $!; 19 19 20 system("Xvnc PasswordFile=/home/tdb01r/.vnc/passwd :20 &");21 22 20 my $sth = $dbh->prepare("SELECT u.id,u.value,n.value FROM live AS u INNER JOIN live AS n USING(id) WHERE u.field='url' AND n.field='name'"); 23 21 $sth->execute; 24 while(my ($id,$url,$name) = $sth->fetchrow_array) { 22 while(my ($id,$url,$name) = $sth->fetchrow_array) 23 { 25 24 next if( $opt_url && $url ne $opt_url ); 26 25 my $fn = uid($name) or die "Unable to create UID for $id/$url"; 27 26 $url =~ s/^https/http/; 28 system("$CGI_ROOT/webcap.sh", $url, "$THUMBNAIL_PATH/$fn"); 27 my $full = "$THUMBNAIL_PATH/$fn.jpg"; 28 my $thumb = "$THUMBNAIL_PATH/${fn}_thumb.jpg"; 29 if( -e $full ) 30 { 31 my @stats = stat($full); 32 #warn "Large rez exists [".(time() - $stats[9])." < ".(60*60*24*7)."]\n"; 33 if( time() - $stats[9] < 60*60*24*7 ) { 34 next; 35 } 36 } 37 #warn "Requesting [$url]\n"; 38 $ua->get('http://coolshiu.ecs.soton.ac.uk/cgi-bin/webshot.pl?url='.uri_escape($url), ':content_file' => $full); 39 system("convert -geometry 160x120 $full $thumb"); 29 40 } 30 31 system("killall Xvnc");32 41 33 42 $dbh->disconnect;