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