| 43 | | my $sizes = $flickr->execute_method('flickr.photos.getSizes', { |
|---|
| 44 | | photo_id => $search_photo->findvalue('@id'), |
|---|
| 45 | | }); |
|---|
| 46 | | next unless $sizes->{success}; |
|---|
| 47 | | |
|---|
| 48 | | my $sizes_doc = $parser->parse_string($sizes->{_content}); |
|---|
| 49 | | my $image_src = |
|---|
| 50 | | $sizes_doc->findvalue(q[/rsp/sizes/size[@label='Square']/@url]); |
|---|
| 51 | | |
|---|
| 52 | | my $entry = Plagger::Entry->new; |
|---|
| 53 | | |
|---|
| 54 | | # get url of photo page |
|---|
| 55 | | # get related details such as title, date, author(?) |
|---|
| | 46 | my $entry = $self->_create_entry($context, $flickr, $parser, $search_photo); |
|---|
| | 47 | $feed->add_entry($entry); |
|---|
| | 53 | sub _create_entry { |
|---|
| | 54 | my ($self, $context, $flickr, $parser, $search_photo) = @_; |
|---|
| | 55 | my $sizes = $flickr->execute_method('flickr.photos.getSizes', { |
|---|
| | 56 | photo_id => $search_photo->findvalue('@id'), |
|---|
| | 57 | }); |
|---|
| | 58 | next unless $sizes->{success}; |
|---|
| | 59 | |
|---|
| | 60 | my $sizes_doc = $parser->parse_string($sizes->{_content}); |
|---|
| | 61 | my $size = $self->conf->{size} || 'Square'; |
|---|
| | 62 | my $image_src = |
|---|
| | 63 | $sizes_doc->findvalue(qq[/rsp/sizes/size[\@label='$size']/\@url]); |
|---|
| | 64 | |
|---|
| | 65 | my $info = $flickr->execute_method('flickr.photos.getInfo', { |
|---|
| | 66 | photo_id => $search_photo->findvalue('@id'), |
|---|
| | 67 | }); |
|---|
| | 68 | next unless $info->{success}; |
|---|
| | 69 | |
|---|
| | 70 | my $info_doc = $parser->parse_string($info->{_content}); |
|---|
| | 71 | my $link = $info_doc->findvalue(q[/rsp/photo/urls/url[@type='photopage']]); |
|---|
| | 72 | my $author = $info_doc->findvalue(q[/rsp/photo/owner/@realname]); |
|---|
| | 73 | $author = $info_doc->findvalue(q[/rsp/photo/owner/@username]) unless $author; |
|---|
| | 74 | my $title = $info_doc->findvalue(q[/rsp/photo/title]); |
|---|
| | 75 | my $date = $info_doc->findvalue(q[/rsp/photo/dates/@posted]); |
|---|
| | 76 | |
|---|
| | 77 | my $description = $context->templatize($self, 'entry-description.tt', { |
|---|
| | 78 | image_src => $image_src, |
|---|
| | 79 | title => $title, |
|---|
| | 80 | link => $link, |
|---|
| | 81 | }); |
|---|
| | 82 | my $epoch = DateTime->from_epoch(epoch => 0, time_zone => '+0000'); |
|---|
| | 83 | |
|---|
| | 84 | my $entry = Plagger::Entry->new; |
|---|
| | 85 | $entry->title($title); |
|---|
| | 86 | $entry->link($link); |
|---|
| | 87 | $entry->body($description); |
|---|
| | 88 | $entry->date(Plagger::Date->parse('Epoch::Unix', $date)); |
|---|
| | 89 | |
|---|
| | 90 | return $entry; |
|---|
| | 91 | } |
|---|
| | 92 | |
|---|