source: web/www/cgi-bin/gutenbach-web.pl @ 9c72c3b

web
Last change on this file since 9c72c3b was 9c72c3b, checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago

Update the web interface to run locally, at least; add a TODO

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/bin/perl
2
3use Net::CUPS;
4use Net::CUPS::Destination;
5use Image::ExifTool qw(ImageInfo);
6use CGI ':standard';
7
8use strict;
9use warnings;
10
11my $cups = Net::CUPS->new();
12$cups->setServer("lbsg.mit.edu");
13my $printer = $cups->getDestination("pikamp3");
14#print header();
15print start_html();
16my @jobs = $printer->getJobs( 0, 0 );
17my $job_ref;
18my $jobid;
19my $attr;
20print  <<EOF;
21<TABLE SUMMARY="Job List" cellpadding="5px"> 
22<THEAD> 
23<TR><TH> USER</TH><TH>TITLE</TH><TH>ARTIST</TH><TH>ALBUM</TH></TR>
24</THEAD>
25<TBODY> 
26EOF
27foreach $jobid(@jobs) 
28{       
29        $job_ref = $printer->getJob($jobid);
30        #print "$job_ref->{ 'id' }\t\t$job_ref->{ 'user'}\t\t$job_ref->{ 'title' }\n";
31        my $filepath = "/var/spool/cups/d00$job_ref->{ 'id' }-001";
32        my $fileinfo = ImageInfo($filepath);
33        my $magic = $fileinfo->{FileType};
34        #print"$job_ref->{ 'user' } is playing:\n";
35        print "<TR VALIGN=\"TOP\">";
36        print "<TD>$job_ref->{ 'user'}</TD>\n";
37        if($magic)
38        {
39           # print "MAGIC";
40            if (exists $fileinfo->{'Title'}) {
41                printf("<TD>%s</TD>\n", $fileinfo->{'Title'});
42            }
43            foreach my $key (qw/Artist Album AlbumArtist/) {
44                if (exists $fileinfo->{$key}) {
45                    printf("<TD>%s</TD>\n", $fileinfo->{$key}) if exists $fileinfo->{$key};
46                   
47                }
48            }
49        }
50        else
51        {
52            print "<TD>$job_ref->{ 'title' }</TD><TD></TD><TD></TD> \n";
53        }
54        print "</TR>";
55
56}
57print "</TBODY>\n</TABLE>";
58       
59print end_html();           
Note: See TracBrowser for help on using the repository browser.