| 1 | package URI::Title::PDF; | ||
| 2 | $URI::Title::PDF::VERSION = '1.902'; | ||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | sub types {( | ||
| 7 | 'application/pdf', | ||
| 8 | )} | ||
| 9 | |||
| 10 | sub title { | ||
| 11 | my ($class, $url, $data, $type) = @_; | ||
| 12 | |||
| 13 | my %fields = (); | ||
| 14 | my $content = URI::Title::_get_end($url) or return; | ||
| 15 | foreach my $i (qw(Producer Creator CreationDate Author Title Subject)) { | ||
| 16 | my @parts = $content =~ m#/$i \((.*?)\)#mgs; | ||
| 17 | $fields{$i} = $parts[-1]; # grab the last one, hopefully right | ||
| 18 | } | ||
| 19 | |||
| 20 | my $title = ""; | ||
| 21 | my @parts = (); | ||
| 22 | if ($fields{Title}) { | ||
| 23 | push @parts, "$fields{Title}"; | ||
| 24 | if ($fields{Author}) { push @parts, "by $fields{Author}"; } | ||
| 25 | if ($fields{Subject}) { push @parts, "($fields{Subject})"; } | ||
| 26 | } | ||
| 27 | if ($fields{Creator} and $fields{Creator} ne 'Not Available') { | ||
| 28 | push @parts, "creator: $fields{Creator}"; | ||
| 29 | } | ||
| 30 | if ($fields{Producer} and $fields{Producer} ne 'Not Available') { | ||
| 31 | push @parts, "produced: $fields{Producer}"; | ||
| 32 | } | ||
| 33 | $title = join(' ', @parts); | ||
| 34 | return $title; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||
| 39 | __END__ |