Changeset 415

Show
Ignore:
Timestamp:
2007-03-13 17:28:33 (2 years ago)
Author:
tdb01r
Message:
  • Use webshot hosted on coolshiu
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/webcap/update.pl

    r294 r415  
    22 
    33use strict; 
     4use warnings; 
    45 
    56use DBI; 
     7use LWP::UserAgent; 
     8use URI::Escape; 
    69 
    7 if( -e "/tmp/webcap.lock" ) 
    8 
    9         die "Looks like an existing thumbshot update is already running"; 
    10 
     10my $ua = LWP::UserAgent->new; 
    1111 
    1212my $opt_url = shift; 
     
    1818my $dbh = DBI->connect("dbi:mysql:database=iar","iar","") or die $!; 
    1919 
    20 system("Xvnc PasswordFile=/home/tdb01r/.vnc/passwd :20 &"); 
    21  
    2220my $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'"); 
    2321$sth->execute; 
    24 while(my ($id,$url,$name) = $sth->fetchrow_array) { 
     22while(my ($id,$url,$name) = $sth->fetchrow_array) 
     23
    2524        next if( $opt_url && $url ne $opt_url ); 
    2625        my $fn = uid($name) or die "Unable to create UID for $id/$url"; 
    2726        $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"); 
    2940} 
    30  
    31 system("killall Xvnc"); 
    3241 
    3342$dbh->disconnect;