Apache-UpnpImgBrowser
view release on metacpan or search on metacpan
UpnpImgBrowser.pm view on Meta::CPAN
Apache::UpnpImgBrowser
=head1 SYNOPSIS
Add the following to your httpd.conf and restart. Then point your browser to
http://yoursite/photos
<Location /photos>
AllowOverride None
#Options -Indexes -Includes -FollowSymLinks
Order allow,deny
Allow from all
SetHandler perl-script
PerlHandler Apache::UpnpImgBrowser
PerlSetVar Basedir Photos/Folder
PerlSetVar Rows 10
PerlSetVar Cols 5
PerlSetVar Thumb-size 50x20
PerlSetVar Show-names 0
PerlSetVar Hide-dirs 1
PerlSetVar Filter vacation
</Location>
=head1 DESCRIPTION
I<Apache::UpnpImgBroswer> is a mod_perl application for displaying photos
hosted on a UPnPAV compliant Media Server. I<Apache::UpnpImgBroswer> will
automatically discover all these types of devices on your network.
=head1 CAVEATS
=over 2
=item B<*> Thumbnails only work with TwonkyVision
=item B<*> Lots of work still to do
=cut
package Apache::UpnpImgBrowser;
use strict;
use Apache2;
use Apache::RequestRec;
use Apache::RequestIO;
use Apache::Const qw(:common HTTP_OK);
use Apache::Log;
use APR::Const qw(:filetype);
use APR::Finfo;
use Image::Magick ();
use DirHandle ();
use FileHandle ();
use File::Basename qw(fileparse);
use Net::UPnP::ControlPoint;
use Net::UPnP::AV::MediaServer;
use SOAP::Lite maptype => {};
use XML::Simple;
use Data::Dumper;
use POSIX qw(strftime);
use Cache::FileCache;
use URI::Escape;
use LWP::Simple;
use vars qw(%gOptions @gOutput $gOutputStarted $gCp @gDeviceList $gLastDir $cache $VERSION);
$VERSION = 0.01;
%gOptions = (
'thumb-size' => '100x75', # set thumbnail size
'force' => 0, # always rebuild thumbnails
'rows' => 5, # rows to display
'cols' => 4, # columns to display
'show-names' => 0, # show thumbnail names
'hide-dirs' => 0, # hide the photo directories list
'filter' => '.*', # display only directories that match
'basedir' => 'Photos', # Base directory of the UPNP server
);
$cache = new Cache::FileCache( { 'namespace' => 'UpnpImgBrowser',
'default_expires_in' => 600 } );
sub handler {
my($r) = shift;
$gCp = $cache->get('cp');
@gDeviceList = $cache->get('device');
if (! defined $gCp) {
$gCp = Net::UPnP::ControlPoint->new();
$cache->set('cp', $gCp);
}
unless (grep ref $_ eq 'Net::UPnP::Device', @gDeviceList) {
@gDeviceList = (upnpInitDevice($r));
$cache->set('device', @gDeviceList);
}
# store output in this array
@gOutput = ();
$gOutputStarted = 0;
# set config values
my $val = '';
$gOptions{'thumb-size'} = $val if($val = $r->dir_config('Thumb-size'));
$gOptions{'force'} = $val if($val = $r->dir_config('Force'));
$gOptions{'rows'} = $val if($val = $r->dir_config('Rows'));
$gOptions{'cols'} = $val if($val = $r->dir_config('Cols'));
$gOptions{'show-names'} = $val if($val = $r->dir_config('Show-names'));
$gOptions{'hide-dirs'} = $val if($val = $r->dir_config('Hide-dirs'));
$gOptions{'basedir'} = $val if($val = $r->dir_config('Basedir'));
$gOptions{'filter'} = $val if($val = $r->dir_config('Filter'));
( run in 2.330 seconds using v1.01-cache-2.11-cpan-f56aa216473 )