debianmacno-cupsweb
|
Last change
on this file since aa5ccdd was
cd17920,
checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago
|
|
Print file names if exiftool doesn't succeed
|
-
Property mode set to
100755
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use Net::CUPS; |
|---|
| 4 | use Net::CUPS::Destination; |
|---|
| 5 | use Image::ExifTool qw(ImageInfo); |
|---|
| 6 | |
|---|
| 7 | use strict; |
|---|
| 8 | use warnings; |
|---|
| 9 | |
|---|
| 10 | use vars qw/$queue/; |
|---|
| 11 | require "/usr/lib/gutenbach/config/gutenbach-filter-config.pl" or die "Unable to load configuration"; |
|---|
| 12 | |
|---|
| 13 | my $cups = Net::CUPS->new(); |
|---|
| 14 | my $printer = $cups->getDestination("$queue"); |
|---|
| 15 | my @jobs = $printer->getJobs( 0, 0 ); |
|---|
| 16 | my $job_ref; |
|---|
| 17 | my $jobid; |
|---|
| 18 | my $attr; |
|---|
| 19 | |
|---|
| 20 | my $jobnum = 0; |
|---|
| 21 | foreach $jobid(@jobs) |
|---|
| 22 | { |
|---|
| 23 | $job_ref = $printer->getJob($jobid); |
|---|
| 24 | my $filepath = "/var/spool/cups/d0$job_ref->{'id'}-001"; |
|---|
| 25 | my $fileinfo = ImageInfo($filepath); |
|---|
| 26 | my $magic = $fileinfo->{FileType}; |
|---|
| 27 | |
|---|
| 28 | if ($jobnum == 0) |
|---|
| 29 | { |
|---|
| 30 | print $job_ref->{'user'}." is currently playing:\n"; |
|---|
| 31 | |
|---|
| 32 | if ($magic) |
|---|
| 33 | { |
|---|
| 34 | print "\t".$magic." file ".$job_ref->{'title'}."\n"; |
|---|
| 35 | foreach my $key (qw/Title Artist Album AlbumArtist/) |
|---|
| 36 | { |
|---|
| 37 | if (exists $fileinfo->{$key}) |
|---|
| 38 | { |
|---|
| 39 | print "\t$fileinfo->{$key}\n"; |
|---|
| 40 | } |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | else |
|---|
| 44 | { |
|---|
| 45 | print "\t".$job_ref->{'title'}."\n"; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | print "\nComing up the queue:\n\n"; |
|---|
| 49 | } |
|---|
| 50 | else |
|---|
| 51 | { |
|---|
| 52 | if ($magic) |
|---|
| 53 | { |
|---|
| 54 | my $user = $job_ref->{'user'}; |
|---|
| 55 | my $title = $fileinfo->{'Title'}; |
|---|
| 56 | my $artist = $fileinfo->{'Artist'}; |
|---|
| 57 | my $album = $fileinfo->{'Album'}; |
|---|
| 58 | print "$user: \"$title\" by \"$artist\" on \"$album\"\n"; |
|---|
| 59 | } |
|---|
| 60 | else |
|---|
| 61 | { |
|---|
| 62 | my $user = $job_ref->{'user'}; |
|---|
| 63 | my $file = $job_ref->{'title'}; |
|---|
| 64 | print "$user: $file\n"; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | $jobnum += 1; |
|---|
| 69 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.