Changeset b58aada for client/bin/gbr
- Timestamp:
- Jul 5, 2010, 8:01:47 PM (14 years ago)
- Branches:
- master, debian, mac, no-cups, web
- Children:
- d768767
- Parents:
- 38388ac
- git-author:
- Jessica B. Hamrick <jhamrick@…> (07/05/10 20:01:47)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (07/05/10 20:01:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/bin/gbr
r38388ac rb58aada 5 5 use strict; 6 6 use warnings; 7 8 use Net::CUPS; 9 use Net::CUPS::Destination; 10 use Image::ExifTool qw(ImageInfo); 7 11 8 12 my $usage = "Usage: gbr QUEUE FILES\n"; … … 31 35 } 32 36 33 $ENV{CUPS_SERVER}="$host"; 37 my $cups = Net::CUPS->new(); 38 $cups->setServer("$host"); 39 my $printer = $cups->getDestination("$queue"); 40 my ($jobid, $title); 34 41 35 42 foreach my $file(@files) { 36 43 if ($file =~ m|http://www\.youtube\.com/watch\?v=|) { 37 open(LP, "|-", "lp", "-d$queue") or die "Couldn't execute lp command"; 38 print LP "$file"; 39 close LP; 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); 40 49 } 41 50 else { 42 my $pid = open(LP, "-|"); 43 if (not $pid) { 44 my @args = ("lp", "-d$queue", "$file"); 45 exec(@args) or die "Couldn't execute lp command"; 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; 46 59 } 47 60 } 48 61 49 print "Sent job '$file'\n"; 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 } 50 70 }
Note: See TracChangeset
for help on using the changeset viewer.