debianmacno-cupsweb
Last change
on this file since b58aada was
b58aada,
checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago
|
Use perl bindings for gbr and gbrm in addition to gbq. Update README.
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Rev | Line | |
---|
[fe74c7c] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # Written by Jessica Hamrick (C) 2010 |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
| 7 | |
---|
[b58aada] | 8 | use Net::CUPS; |
---|
| 9 | use Net::CUPS::Destination; |
---|
| 10 | use Image::ExifTool qw(ImageInfo); |
---|
| 11 | |
---|
[38388ac] | 12 | my $usage = "Usage: gbr QUEUE FILES\n"; |
---|
[fe74c7c] | 13 | |
---|
| 14 | my $q = $ARGV[0]; |
---|
[38388ac] | 15 | my @files = @ARGV[1 .. $#ARGV]; |
---|
[fe74c7c] | 16 | |
---|
[38388ac] | 17 | if (!$q or !@files) { |
---|
[fe74c7c] | 18 | print $usage; |
---|
| 19 | exit 1 |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; |
---|
[85a1ac1] | 23 | if (! -e $configpath) { |
---|
| 24 | print "Queue '$q' does not exist!\n"; |
---|
| 25 | exit 1; |
---|
| 26 | } |
---|
| 27 | |
---|
[fe74c7c] | 28 | my ($host, $queue); |
---|
| 29 | |
---|
| 30 | if (-r $configpath) { |
---|
| 31 | local $/; |
---|
| 32 | my $fh; |
---|
| 33 | open $fh, $configpath; |
---|
| 34 | eval <$fh>; |
---|
| 35 | } |
---|
| 36 | |
---|
[b58aada] | 37 | my $cups = Net::CUPS->new(); |
---|
| 38 | $cups->setServer("$host"); |
---|
| 39 | my $printer = $cups->getDestination("$queue"); |
---|
| 40 | my ($jobid, $title); |
---|
[c5a98db] | 41 | |
---|
[38388ac] | 42 | foreach my $file(@files) { |
---|
| 43 | if ($file =~ m|http://www\.youtube\.com/watch\?v=|) { |
---|
[b58aada] | 44 | open FILE, ">", "/tmp/gutenbach-youtube\n" or die "Couldn't create temporary file"; |
---|
| 45 | print FILE $file; |
---|
| 46 | $title = $file; |
---|
| 47 | $file = "/tmp/gutenbach-youtube"; |
---|
| 48 | $printer->addOption("copies", 42); |
---|
[38388ac] | 49 | } |
---|
| 50 | else { |
---|
[b58aada] | 51 | my $fileinfo = ImageInfo($file); |
---|
| 52 | my $magic = $fileinfo->{FileType}; |
---|
| 53 | |
---|
| 54 | if ($magic) { |
---|
| 55 | $title = $fileinfo->{'Title'}." - ".$fileinfo->{'Artist'}." - ".$fileinfo->{'Album'}; |
---|
| 56 | } |
---|
| 57 | else { |
---|
| 58 | $title = $file; |
---|
[38388ac] | 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
[b58aada] | 62 | $jobid = $printer->printFile($file, $title); |
---|
| 63 | |
---|
| 64 | if ($jobid) { |
---|
| 65 | print "Sent job '$title' (id $jobid)\n"; |
---|
| 66 | } |
---|
| 67 | else { |
---|
| 68 | print "Error sending job '$title'\n"; |
---|
| 69 | } |
---|
[c5a98db] | 70 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.