line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::PMP::Profile::Media; |
2
|
1
|
|
|
1
|
|
1099
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
extends 'Net::PMP::Profile'; |
4
|
1
|
|
|
1
|
|
6041
|
use Net::PMP::Profile::MediaEnclosure; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
7
|
use Media::Type::Simple; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
102
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
255
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.102'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'enclosure' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'Net::PMP::Type::MediaEnclosures', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
coerce => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
0
|
sub get_profile_url {'https://api.pmp.io/profiles/media'} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get_type_from_uri { |
20
|
3
|
|
|
3
|
1
|
3759
|
my $self = shift; |
21
|
3
|
50
|
|
|
|
9
|
my $uri = shift or confess "uri required"; |
22
|
3
|
|
|
|
|
12
|
$uri =~ s/\?.*//; |
23
|
3
|
|
|
|
|
17
|
$uri =~ s/.+\.(\w+)$/$1/; |
24
|
|
|
|
|
|
|
my $type = try { |
25
|
3
|
|
|
3
|
|
184
|
type_from_ext( lc $uri ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
catch { |
28
|
0
|
|
|
0
|
|
0
|
confess $_; # re-throw with full stack trace |
29
|
3
|
|
|
|
|
22
|
}; |
30
|
3
|
|
|
|
|
510
|
return $type; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_urn { |
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
( my $profile_name = $self->get_profile_url ) =~ s,^.+/,,; |
36
|
0
|
|
|
|
|
|
return 'urn:collectiondoc:' . $profile_name; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Net::PMP::Profile::Media - Rich Media Profile for PMP CollectionDoc |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use Net::PMP; |
52
|
|
|
|
|
|
|
use Net::PMP::Profile::Media; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $media = Net::PMP::Profile::Media->new( |
55
|
|
|
|
|
|
|
title => 'I am A Title', |
56
|
|
|
|
|
|
|
published => '2013-12-03T12:34:56.789Z', |
57
|
|
|
|
|
|
|
valid => { |
58
|
|
|
|
|
|
|
from => "2013-04-11T13:21:31.598Z", |
59
|
|
|
|
|
|
|
to => "3013-04-11T13:21:31.598Z", |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
byline => 'By: John Writer and Nancy Author', |
62
|
|
|
|
|
|
|
description => 'This is a summary of the document.', |
63
|
|
|
|
|
|
|
tags => [qw( foo bar baz )], |
64
|
|
|
|
|
|
|
enclosure => [ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
], |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# instantiate a client |
70
|
|
|
|
|
|
|
my $client = Net::PMP->client( |
71
|
|
|
|
|
|
|
host => $host, |
72
|
|
|
|
|
|
|
id => $client_id, |
73
|
|
|
|
|
|
|
secret => $client_secret, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# save doc |
77
|
|
|
|
|
|
|
$client->save($media); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Net::PMP::Profile::Media implements the CollectionDoc fields for the PMP Rich Media Profile |
84
|
|
|
|
|
|
|
L<https://github.com/publicmediaplatform/pmpdocs/wiki/Rich-Media-Profiles>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This class extends L<Net::PMP::Profile>. Only new or overridden methods are documented here. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 enclosure |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Required array of hashrefs or Net::PMP::Profile::MediaEnclosure objects representing the binary file of the media asset. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 get_profile_url |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns a string for the PMP profile's URL. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 get_urn |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns a string for the PMP link rels attribute. Defaults to C<urn:collectiondoc:>I<profile_name>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 get_type_from_uri( I<uri> ) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns MIME type for I<uri>. Uses L<Media::Type::Simple> and assumes I<uri> has a recognizable filename |
105
|
|
|
|
|
|
|
extension. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Peter Karman, C<< <karman at cpan.org> >> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through |
114
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP-Profile>. I will be notified, and then you'll |
115
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SUPPORT |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
perldoc Net::PMP |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
You can also look for information at: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item IRC |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Join #pmp on L<http://freenode.net>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item RT: CPAN's request tracker (report bugs here) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP-Profile> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item AnnoCPAN: Annotated CPAN documentation |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Net-PMP-Profile> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item CPAN Ratings |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Net-PMP-Profile> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item Search CPAN |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Net-PMP-Profile/> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
American Public Media and the Public Media Platform sponsored the development of this module. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright 2013 American Public Media Group |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
See the LICENSE file that accompanies this module. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |