/usr/share/perl5/URI/Title/PDF.pm is in liburi-title-perl 1.89-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | =head1 NAME
URI::Title::PDF - get titles of PDF files
=cut
package URI::Title::PDF;
use warnings;
use strict;
sub types {(
'application/pdf',
)}
sub title {
my ($class, $url, $data, $type) = @_;
my %fields = ();
my $content = URI::Title::get_end($url) or return;
foreach my $i (qw(Producer Creator CreationDate Author Title Subject)) {
my @parts = $content =~ m#/$i \((.*?)\)#mgs;
$fields{$i} = $parts[-1]; # grab the last one, hopefully right
}
my $title = "";
my @parts = ();
if ($fields{Title}) {
push @parts, "$fields{Title}";
if ($fields{Author}) { push @parts, "by $fields{Author}"; }
if ($fields{Subject}) { push @parts, "($fields{Subject})"; }
}
if ($fields{Creator} and $fields{Creator} ne 'Not Available') {
push @parts, "creator: $fields{Creator}";
}
if ($fields{Producer} and $fields{Producer} ne 'Not Available') {
push @parts, "produced: $fields{Producer}";
}
$title = join(' ', @parts);
return $title;
}
1;
|