line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flickr::API2::Photos; |
2
|
4
|
|
|
4
|
|
33
|
use 5.12.0; |
|
4
|
|
|
|
|
8
|
|
3
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
77
|
|
4
|
4
|
|
|
4
|
|
1778
|
use Moo; |
|
4
|
|
|
|
|
39163
|
|
|
4
|
|
|
|
|
20
|
|
5
|
4
|
|
|
4
|
|
5698
|
use Flickr::API2::Photo; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
128
|
|
6
|
4
|
|
|
4
|
|
24
|
use Carp qw(croak); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1042
|
|
7
|
|
|
|
|
|
|
extends 'Flickr::API2::Base'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Flickr::API2::Photos |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
See search() and by_id() methods below. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 by_id |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Finds one photo by its id number. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
eg. say $api->photos->by_id(3386874895)->title; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub by_id { |
28
|
1
|
|
|
1
|
1
|
13
|
my ($self, $id) = @_; |
29
|
1
|
|
|
|
|
17
|
my $p = Flickr::API2::Photo->new( api => $self->api, id => $id ); |
30
|
1
|
|
|
|
|
27
|
my $info = $p->info->{photo}; |
31
|
1
|
|
|
|
|
7
|
$p->title($info->{title}{_content}); |
32
|
1
|
|
|
|
|
5
|
$p->description($info->{description}{_content}); |
33
|
1
|
|
|
|
|
3
|
$p->owner_name($info->{owner}{realname}); |
34
|
1
|
|
|
|
|
4
|
$p->owner_id($info->{owner}{nsid}); |
35
|
1
|
|
|
|
|
2
|
$p->path_alias($info->{owner}{username}); |
36
|
1
|
|
|
|
|
5
|
$p->license($info->{license}); |
37
|
1
|
|
|
|
|
3
|
$p->tags($info->{tags}{tag}); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
13
|
return $p; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 search |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Search for photos, for eg: |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my @photos = $flickr->photos->search(tags => 'kitten,pony'); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
For parameters, see: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
http://www.flickr.com/services/api/flickr.photos.search.html |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This returns an array of Flickr::API2::Photo objects. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub search { |
57
|
1
|
|
|
1
|
1
|
16
|
my $self = shift; |
58
|
1
|
|
|
|
|
4
|
my %args = @_; |
59
|
1
|
|
50
|
|
|
11
|
$args{extras} ||= join(',', |
60
|
|
|
|
|
|
|
qw( |
61
|
|
|
|
|
|
|
date_upload date_taken owner_name url_s url_m url_l url_o path_alias |
62
|
|
|
|
|
|
|
) |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
10
|
my $r = $self->api->execute_method( |
66
|
|
|
|
|
|
|
'flickr.photos.search', \%args |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
croak("Didn't understand response (or no photos)") |
69
|
1
|
50
|
|
|
|
9
|
unless exists $r->{photos}; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
20
|
return $self->_response_to_photos($r->{photos}); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |