blib/lib/Net/Flickr/Backup.pm

filter: Statementstmt 13.1% 65 / 496 Branchbran 0.0% 0 / 166 Conditioncond 0.0% 0 / 58 MC/DCmcdc 0.0% 0 / 35 Subroutinesub 44.4% 20 / 45 Podpod 50.0% 7 / 14 totaltotal 11.3% 92 / 814 SCAR 91.5
CC
111
Cov
9%
backup_photo
1260.0
backup
380.0
store_rdf
342.0
CRAP 9387.2
↑ Summary Build »
1 # $Id: Backup.pm,v 1.107 2010/12/19 19:06:56 asc Exp $
2 # -*-perl-*-
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 package Net::Flickr::Backup;
8 1 ▶use base qw (Net::Flickr::RDF);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 $Net::Flickr::Backup::VERSION = '3.1';
11  
12 =head1 NAME
13  
14 Net::Flickr::Backup - OOP for backing up your Flickr photos locally
15  
16 =head1 SYNOPSIS
17  
18 use Net::Flickr::Backup;
19 use Log::Dispatch::Screen;
20
21 my $flickr = Net::Flickr::Backup->new($cfg);
22  
23 my $feedback = Log::Dispatch::Screen->new('name' => 'info',
24 'min_level' => 'info');
25  
26 $flickr->log()->add($feedback);
27 $flickr->backup();
28  
29 =head1 DESCRIPTION
30  
31 OOP for backing up your Flickr photos locally.
32  
33 =head1 OPTIONS
34  
35 Options are passed to Net::Flickr::Backup using a Config::Simple object or
36 a valid Config::Simple config file. Options are grouped by "block".
37  
38 =head2 flickr
39  
40 =over 4
41  
42 =item * B<api_key>
43  
44 String. I<required>
45  
46 A valid Flickr API key.
47  
48 =item * B<api_secret>
49  
50 String. I<required>
51  
52 A valid Flickr Auth API secret key.
53  
54 =item * B<auth_token>
55  
56 String. I<required>
57  
58 A valid Flickr Auth API token.
59  
60 The B<api_handler> defines which XML/XPath handler to use to process API responses.
61  
62 =over 4
63  
64 =item * B<LibXML>
65  
66 Use XML::LibXML.
67  
68 =item * B<XPath>
69  
70 Use XML::XPath.
71  
72 =back
73  
74 =back
75  
76 =head2 backup
77  
78 =over 4
79  
80 =item * B<photos_root>
81  
82 String. I<required>
83  
84 The root folder where you want photographs to be stored. Individual
85 files are named using the following pattern :
86  
87 B<photos_root>/B<YYYY>/B<MM>/B<DD>/B<YYYYMMDD>-B<photo_id>-B<clean_title>_B<size>.jpg
88  
89 Where the various components are :
90  
91 =over 4
92  
93 =item * B<YYYYMMDD>
94  
95 photo[@id=123]/dates/@taken
96  
97 =item * B<photo_id>
98  
99 photo/@id
100  
101 =item * B<clean_title>
102  
103 photo[@id=123]/title
104  
105 Unicode characters translated in to ASCII (using Text::Unidecode) and the
106 entire string is stripped anything that is not an alphanumeric, underbar,
107 dash or a square bracket.
108  
109 =item * B<size>
110  
111 Net::Flickr::Backup will attempt to fetch not only the original file uploaded
112 to Flickr but also, depending on your config options, the medium and square
113 versions. Filenames will be modified as follows :
114  
115 =over 4
116  
117 =item * B<original>
118  
119 The original photo you uploaded to the Flickr servers. No extension is
120 added.
121  
122 =item * B<medium>
123  
124 These photos are scaled to 500 pixels at the longest dimension. A B<_m>
125 extension is added.
126  
127 =item * B<medium_640>
128  
129 These photos are scaled to 640 pixels at the longest dimension. A B<_z>
130 extension is added.
131  
132 =item * B<square>
133  
134 These photos are to cropped to 75 x 75 pixels at the center. A B<_s>
135 extension is added.
136  
137 =item * B<site_mp4>
138  
139 The MP4 version of a video uploaded to Flickr. A B<_site> extension is added.
140  
141 =item * B<video_original>
142  
143 An original video uploaded to Flickr. No extentsion is added.
144  
145 =back
146  
147 =back
148  
149 =item * B<fetch_original>
150  
151 Boolean.
152  
153 Retrieve the "original" version of a photo from the Flickr servers.
154  
155 Default is true.
156  
157 =item * B<fetch_video_original>
158  
159 Boolean.
160  
161 Retrieve the "original" version of a video from the Flickr servers.
162  
163 Default is true.
164  
165 =item * B<fetch_medium>
166  
167 Boolean.
168  
169 Retrieve the "medium" version of a photo from the Flickr servers; these photos
170 have been scaled to 500 pixels at the longest dimension.
171  
172 Default is false.
173  
174 =item * B<fetch_medium_640>
175  
176 Boolean.
177  
178 Retrieve the "medium" version of a photo from the Flickr servers; these photos
179 have been scaled to 640 pixels at the longest dimension.
180  
181 Default is false.
182  
183 =item * B<fetch_square>
184  
185 Boolean.
186  
187 Retrieve the "square" version of a photo from the Flickr servers; these photos
188 have been cropped to 75 x 75 pixels at the center.
189  
190 Default is false.
191  
192 =item * B<fetch_site_mp4>
193  
194 Boolean.
195  
196 Retrieve the "site MP4" version of a video from the Flickr servers;
197  
198 Default is false.
199  
200 =item * B<scrub_backups>
201  
202 Boolean.
203  
204 If true then, for each Flickr photo ID backed up, the library will check
205 B<backup.photos_root> for images (and metadata files) with a matching ID but
206 a different name. Matches will be deleted.
207  
208 =item * B<force>
209  
210 Boolean.
211  
212 Force a photograph to be backed up even if it has not changed.
213  
214 Default is false.
215  
216 =back
217  
218 =head2 rdf
219  
220 =over 4
221  
222 =item * B<do_dump>
223  
224 Boolean.
225  
226 Generate an RDF description for each photograph. Descriptions
227 are written to disk in separate files.
228  
229 Default is false.
230  
231 =item * B<rdfdump_root>
232  
233 String.
234  
235 The path where RDF data dumps for a photo should be written. The default
236 is the same path as B<backup.photos_root>.
237  
238 File names are generated with the same pattern used to name
239 photographs.
240  
241 =item * B<rdfdump_inline>
242  
243 Boolean.
244  
245 Set to true if you want the RDF dump for a photo to be stored in the file's
246 JPEG COM block. RDF data will only be stored (for the time being) in the original
247 image file and not any of the scaled versions.
248  
249 This option will only work for JPEG files and is still B<experimental>. It may change
250 or, you know, not always work. Using Adobe's XMP spec is on the list of things to poke
251 at so if you've got any suggestions on the subject, they'd be welcome.
252  
253 Default is false.
254  
255 =item * B<photos_alias>
256  
257 String.
258  
259 If defined this string is applied as regular expression substitution to
260 B<backup.photos_root>.
261  
262 Default is to append the B<file:/> URI protocol to a path.
263  
264 =item * B<query_geonames>
265  
266 Boolean.
267  
268 If true and a photo has geodata (latitude, longitude) associated with it, then
269 the geonames.org database will be queried for a corresponding match. Data will be
270 added as properties of the photo's geo:Point description. For example :
271  
272 <geo:Point rdf:about="http://www.flickr.com/photos/35034348999@N01/272880469#location">
273 <geo:long>-122.025151</geo:long>
274 <flickr:accuracy>16</flickr:accuracy>
275 <acl:access>visbility</acl:access>
276 <geo:lat>37.417839</geo:lat>
277 <acl:accessor>public</acl:accessor>
278 <geoname:Feature rdf:resource="http://ws.geonames.org/rdf?geonameId=5409655"/>
279 </geo:Point>
280  
281 <geoname:Feature rdf:about="http://ws.geonames.org/rdf?geonameId=5409655">
282 <geoname:featureCode>PPLX</geoname:featureCode>
283 <geoname:countryCode>US</geoname:countryCode>
284 <geoname:regionCode>CA</geoname:regionCode>
285 <geoname:region>California</geoname:region>
286 <geoname:city>Santa Clara</geoname:city>
287 <geoname:gtopo30>2</geoname:gtopo30>
288 </geoname:Feature>
289  
290 =back
291  
292 =head2 iptc
293  
294 =over 4
295  
296 =item * B<do_dump>
297  
298 Boolean.
299  
300 If true, then a limited set of metadata associated with a photo will be stored
301 as IPTC information.
302  
303 A photo's title is stored as the IPTC B<Headline>, description as B<Caption/Abstract>
304 and tags are stored in one or more B<Keyword> headers. Per the IPTC 7901 spec,
305 all text is converted to the ISO-8859-1 character encoding.
306  
307 For example :
308  
309 exiv2 -pi /home/asc/photos/2006/06/20/20060620-171674319-mie.jpg
310 Iptc.Application2.RecordVersion Short 1 2
311 Iptc.Application2.Keywords String 11 cameraphone
312 Iptc.Application2.Keywords String 15 "san francisco"
313 Iptc.Application2.Keywords String 5 filtr
314 Iptc.Application2.Keywords String 3 mie
315 Iptc.Application2.Keywords String 20 upcoming:event=77752
316 Iptc.Application2.Headline String 3 Mie
317  
318 Default is false.
319  
320 =back
321  
322 =head2 search
323  
324 Any valid parameter that can be passed to the I<flickr.photos.search>
325 method B<except> 'user_id' which is pre-filled with the user_id that
326 corresponds to the B<flickr.auth_token> token.
327  
328 =head2 modified_since
329  
330 String.
331  
332 This specifies a time-based limiting criteria for fetching photos.
333  
334 The syntax is B<(n)(modifier)> where B<(n)> is a positive integer and B<(modifier)>
335 may be one of the following :
336  
337 =over 4
338  
339 =item * B<h>
340  
341 Fetch photos that have been modified in the last B<(n)> hours.
342  
343 =item * B<d>
344  
345 Fetch photos that have been modified in the last B<(n)> days.
346  
347 =item * B<w>
348  
349 Fetch photos that have been modified in the last B<(n)> weeks.
350  
351 =item * B<M>
352  
353 Fetch photos that have been modified in the last B<(n)> months.
354  
355 =back
356  
357 =cut
358  
359 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
360 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
361 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
362 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
363  
364 1 ▶use Text::Unidecode;
Subroutine BEGIN: called CC=1 SCAR=0.0
365  
366 1 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
367 1 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
368 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
369 1 ▶use File::Find::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
370  
371 1 ▶use DirHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
372  
373 1 ▶use IO::AtomicFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
374 1 ▶use IO::Scalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
375 1 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
376 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
377 1 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
378  
379 1 ▶use Memoize;
Subroutine BEGIN: called CC=1 SCAR=0.0
380 1 ▶use Sys::Hostname;
Subroutine BEGIN: called CC=1 SCAR=0.0
381  
382 1 Readonly::Hash my %FETCH_SIZES => (
383 'Original' => '',
384 'Medium' => '_m',
385 'Medium 640' => '_z',
386 'Square' => '_s',
387 'Video Original' => '',
388 'Site MP4' => '_site',
389 );
390  
391 1 Readonly::Scalar my $FLICKR_URL => "http://www.flickr.com/";
392 1 Readonly::Scalar my $FLICKR_URL_PHOTOS => $FLICKR_URL . "photos/";
393  
394 =head1 PACKAGE METHODS
395  
396 =cut
397  
398 =head2 __PACKAGE__->new($cfg)
399  
400 Returns a I<Net::Flickr::Backup> object.
401  
402 =cut
403  
404 # Defined in Net::Flickr::API
405  
406 sub init {
407 0 ▶ my $self = shift;
Subroutine init: not called CC=4 SCAR=30.0
Pod undocumented
408 0 my $cfg = shift;
409
410 0 ▶ if (! $self->SUPER::init($cfg)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->SUPER::init($cfg)) 0 0 0
411 0 return undef;
412 }
413
414 #
415 # Ensure that we have 'flickr' and 'backup'
416 # config blocks
417 #
418  
419 0 foreach my $block ('flickr', 'backup') {
420
421 0 my $test = $self->{cfg}->param(-block=>$block);
422
423 0 ▶ if (! keys %$test) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %$test) 0 0 0
424 0 $self->log()->error("unable to find any properties for $block block in config file");
425 0 return undef;
426 }
427 }
428  
429 #
430  
431 0 $self->{'__lastmod_since'} = 0;
432 0 $self->{'__callbacks'} = {};
433 0 $self->{'__cancel'} = 0;
434  
435 0 $self->{'__hostname'} = undef;
436  
437 #
438  
439 0 memoize("_clean");
440 0 return 1;
441 }
442  
443 =head1 OBJECTS METHODS YOU SHOULD CARE ABOUT
444  
445 =cut
446  
447 =head2 $obj->backup()
448  
449 Returns true or false.
450  
451 =cut
452  
453 sub backup {
454 0 ▶ my $self = shift;
Subroutine backup: not called CC=19 SCAR=59.4
Pod documented
455 0 my $args = shift;
456
457 0 my $auth = $self->get_auth();
458
459 0 ▶ if (! $auth) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($auth) 0 0 0
460 0 return 0;
461 }
462
463 #
464 #
465 #
466  
467 0 my $photos_root = $self->{cfg}->param("backup.photos_root");
468
469 0 ▶ if (! $photos_root) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($photos_root) 0 0 0
470 0 $self->log()->error("no photo root defined, exiting");
471 0 return 0;
472 }
473
474 #
475 #
476 #
477  
478 0 my $poll_meth = "flickr.photos.search";
479 0 my $poll_args = $self->{cfg}->param(-block=>"search");
480  
481 0 $poll_args->{'user_id'} = $auth->find("/rsp/auth/user/\@nsid")->string_value();
482  
483 0 ▶ if (my $min_date = $self->{cfg}->param("search.modified_since")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $min_date = $self->{"cfg"}->param("search.modified_since")) 0 0 0
484  
485 0 ▶ if ($min_date !~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($min_date =~ /^\d+$/) 0 0 0
486 0 $min_date = &_mk_mindate($min_date);
487  
488 0 ▶ if (! $min_date) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($min_date) 0 0 0
489 0 $self->log()->error("unable to parse min date criteria, exiting");
490 0 return 0;
491 }
492 }
493  
494 0 $poll_meth = "flickr.photos.recentlyUpdated";
495 0 $poll_args = {min_date => $min_date};
496  
497 0 $self->{'__lastmod_since'} = $min_date;
498 }
499  
500 #
501 #
502 #
503  
504 0 $self->log()->info("search args ($poll_meth) : " . Dumper($poll_args));
505  
506 #
507 #
508 #
509  
510 0 my $num_pages = 0;
511 0 my $current_page = 1;
512
513 0 my $poll = 1;
514
515 0 ▶ while ($poll) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poll) 0 0 0
516
517 0 ▶ if ($self->{'__cancel'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__cancel"}) 0 0 0
518 0 last;
519 }
520  
521 0 $poll_args->{page} = $current_page;
522
523 #
524
525 0 my $photos = $self->api_call({"method" => $poll_meth,
526 args => $poll_args});
527
528 0 ▶ if (! $photos) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($photos) 0 0 0
529 0 return 0;
530 }
531  
532 #
533  
534 0 ▶ if (($current_page == 1) && ($self->_has_callback("start_backup_queue"))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_page == 1 and $self->_has_callback("start_backup_queue")) 0 0 0
Condition0%0/3
$current_page == 1 and $self->_has_callback("start_backup_queue")
!ll&&!rl&&r
000
MC/DC0%0/2
$current_page == 1 and $self->_has_callback("start_backup_queue")
$current_page == 1 $self->_has_callback("start_backup_queue")
Truth table0%0/3
A and B
A= $current_page == 1B= $self->_has_callback("start_backup_queue")
ABresult
0X0
100
111
535 0 $self->_execute_callback("start_backup_queue", $photos);
536 }
537
538 0 $num_pages = $photos->find("/rsp/photos/\@pages")->string_value();
539  
540 #
541
542 0 foreach my $node ($photos->findnodes("/rsp/photos/photo")) {
543
544 0 ▶ if ($self->{'__cancel'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__cancel"}) 0 0 0
545 0 last;
546 }
547  
548 0 $self->{'__files'} = {};
549
550 0 my $id = $node->getAttribute("id");
551 0 my $secret = $node->getAttribute("secret");
552
553 0 $self->log()->info(sprintf("process image %s (%s)",
554 $id, &_clean($node->getAttribute("title"))));
555
556 #
557  
558 0 ▶ if ($self->_has_callback("start_backup_photo")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_callback("start_backup_photo")) 0 0 0
559 0 $self->_execute_callback("start_backup_photo", $node);
560 }
561
562 0 my $ok = $self->backup_photo($id, $secret);
563  
564 0 ▶ if ($self->_has_callback("finish_backup_photo")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_callback("finish_backup_photo")) 0 0 0
565 0 $self->_execute_callback("finish_backup_photo", $node, $ok);
566 }
567  
568 }
569
570 0 ▶ if ($current_page >= $num_pages) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_page >= $num_pages) 0 0 0
571 0 $poll = 0;
572 }
573
574 0 $current_page ++;
575 }
576
577 #
578  
579 0 ▶ if ($self->_has_callback("finish_backup_queue")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_callback("finish_backup_queue")) 0 0 0
580 0 $self->_execute_callback("finish_backup_queue");
581 }
582
583 #
584
585 0 ▶ if ((! $self->{'__cancel'}) && ($self->{cfg}->param("backup.scrub_backups"))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"__cancel"} and $self->{"cfg"}->param("backup.scrub_backups")) 0 0 0
Condition0%0/3
not $self->{"__cancel"} and $self->{"cfg"}->param("backup.scrub_backups")
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"__cancel"} and $self->{"cfg"}->param("backup.scrub_backups")
not $self->{"__cancel"} $self->{"cfg"}->param("backup.scrub_backups")
Truth table0%0/3
not(A) and B
A= not $self->{"__cancel"}B= $self->{"cfg"}->param("backup.scrub_backups")
ABresult
0X0
100
111
586 0 $self->log()->info("scrubbing backups");
587 0 $self->scrub();
588 }
589
590 0 return 1;
591 }
592  
593 =head1 OBJECT METHODS YOU MAY CARE ABOUT
594  
595 =cut
596  
597 =head2 $obj->backup_photo($id,$secret)
598  
599 Backup an individual photo. This method is called internally by
600 I<backup>.
601  
602 =cut
603  
604 sub backup_photo {
605 0 ▶ my $self = shift;
Subroutine backup_photo: not called CC=35 SCAR=71.4
Pod documented
606 0 my $id = shift;
607 0 my $secret = shift;
608
609 # FIX ME : add 'skip' hash containing id+secret
610 # If there is a problem storing photo data, ensure
611 # that it is not accidentally scrubbed.
612  
613 0 ▶ if (! $self->get_auth()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->get_auth) 0 0 0
614 0 return 0;
615 }
616
617 #
618
619 0 my $force = $self->{cfg}->param("backup.force");
620 0 my $photos_root = $self->{cfg}->param("backup.photos_root");
621
622 0 ▶ if (! $photos_root) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($photos_root) 0 0 0
623 0 $self->log()->error("no photo root defined, exiting");
624 0 return 0;
625 }
626
627 #
628  
629 0 my $info = $self->api_call({method =>"flickr.photos.getInfo",
630 args => {'photo_id' => $id,
631 'secret' => $secret}});
632
633 0 ▶ if (! $info) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info) 0 0 0
634 0 return 0;
635 }
636
637 0 $self->{'_scrub'}->{$id} = [];
638
639 0 my $img = ($info->findnodes("/rsp/photo"))[0];
640
641 0 ▶ if (! $img) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($img) 0 0 0
642 0 return 0;
643 }
644
645 0 my $dates = ($img->findnodes("dates"))[0];
646
647 0 my $last_update = $dates->getAttribute("lastupdate");
648 0 my $has_changed = 1;
649
650 #
651
652 0 my %data = (photo_id => $id,
653 user_id => $img->find("owner/\@nsid")->string_value(),
654 title => $img->find("title")->string_value(),
655 taken => $dates->getAttribute("taken"),
656 posted => $dates->getAttribute("posted"),
657 lastmod => $last_update);
658
659 #
660
661 0 ▶ my $title = &_clean($data{title}) || "untitled";
Condition0%0/2
&_clean($data{'title'}) || 'untitled'
l!l
00
MC/DC0%0/1
&_clean($data{'title'}) || 'untitled'
&_clean($data{'title'})
Truth table0%0/2
A
A= &_clean($data{'title'})
Aresult
11
00
662  
663 0 my $dt = $data{taken};
664
665 0 $dt =~ /^(\d{4})-(\d{2})-(\d{2})/;
666 0 my ($yyyy,$mm,$dd) = ($1,$2,$3);
667
668 #
669
670 0 my $sizes = $self->api_call({method => "flickr.photos.getSizes",
671 args => {photo_id => $id}});
672
673 0 ▶ if (! $sizes) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sizes) 0 0 0
674 0 return 0;
675 }
676
677 #
678
679 0 my $fetch_cfg = $self->{cfg}->param(-block=>"backup");
680
681 0 my $files_modified = 0;
682  
683 0 foreach my $label (keys %FETCH_SIZES) {
684
685 0 my $fetch_label = lc($label);
686 0 $fetch_label =~ s/ /_/g;
687  
688 0 my $fetch_param = "fetch_" . $fetch_label;
689 0 my $do_fetch = 1;
690
691 0 ▶ if (($label !~ /Original/) || (exists($fetch_cfg->{$fetch_param}))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $label =~ /Original/ or exists $fetch_cfg->{$fetch_param}) 0 0 0
Condition0%0/3
not $label =~ /Original/ or exists $fetch_cfg->{$fetch_param}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $label =~ /Original/ or exists $fetch_cfg->{$fetch_param}
not $label =~ /Original/ exists $fetch_cfg->{$fetch_param}
Truth table0%0/3
not(A) or B
A= not $label =~ /Original/B= exists $fetch_cfg->{$fetch_param}
ABresult
1X1
011
000
692 0 $do_fetch = $fetch_cfg->{$fetch_param};
693 }
694
695 0 ▶ if (! $do_fetch) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($do_fetch) 0 0 0
696 0 $self->log()->debug("$fetch_param option is false, skipping");
697 0 next;
698 }
699
700 #
701
702 0 my $sz = ($sizes->findnodes("/rsp/sizes/size[\@label='$label']"))[0];
703
704 0 ▶ if (! $sz) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sz) 0 0 0
705 0 $self->log()->warning("Unable to locate size info for key $label\n");
706 0 next;
707 }
708
709 0 my $source = $sz->getAttribute("source");
710  
711 0 my $ext = 'jpg';
712  
713 0 ▶ if (($label eq 'Site MP4') || ($label eq 'Video Original')){
Branch: 1 branch
BranchTrueFalseTotal
if ($label eq "Site MP4" or $label eq "Video Original") 0 0 0
Condition0%0/3
$label eq "Site MP4" or $label eq "Video Original"
l!l&&r!l&&!r
000
MC/DC0%0/2
$label eq "Site MP4" or $label eq "Video Original"
$label eq "Site MP4" $label eq "Video Original"
Truth table0%0/3
A or B
A= $label eq "Site MP4"B= $label eq "Video Original"
ABresult
1X1
011
000
714  
715 0 my $ua = LWP::UserAgent->new();
716 0 my $req = HTTP::Request->new('HEAD' => $source);
717 0 my $res = $ua->request($req);
718 0 my $headers = $res->headers();
719 0 my $disp = $headers->{"content-disposition"};
720  
721 0 $disp =~ /\.([^\.]+)$/;
722 0 $ext = $1;
723  
724 0 $self->log()->info("video! $source has $disp becomes $ext");
725 }
726  
727 0 my $img_root = File::Spec->catdir($photos_root, $yyyy, $mm, $dd);
728 0 my $img_fname = sprintf("%04d%02d%02d-%s-%s%s.%s", $yyyy, $mm, $dd, $id, $title, $FETCH_SIZES{$label}, $ext);
729
730 0 $self->log()->info("scrub-store $img_fname");
731 0 push @{$self->{'_scrub'}->{$id}}, $img_fname;
732
733 0 my $img_bak = File::Spec->catfile($img_root, $img_fname);
734 0 $self->{'__files'}->{$label} = $img_bak;
735
736 #
737
738 0 ▶ if ((-s $img_bak) && (! $force)){
Branch: 1 branch
BranchTrueFalseTotal
if (-s $img_bak and not $force) 0 0 0
Condition0%0/3
-s $img_bak and not $force
!ll&&!rl&&r
000
MC/DC0%0/2
-s $img_bak and not $force
-s $img_bak not $force
Truth table0%0/3
A and not(B)
A= -s $img_bakB= not $force
ABresult
0X0
100
111
739  
740 0 ▶ if (! $has_changed){
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_changed) 0 0 0
741 0 $self->log()->info("$img_bak has not changed, skipping\n");
742 0 next;
743 }
744
745 0 my $mtime = (stat($img_bak))[9];
746
747 0 ▶ if ((-f $img_bak) && ($last_update) && ($mtime >= $last_update)){
Branch: 1 branch
BranchTrueFalseTotal
if (-f $img_bak and $last_update and $mtime >= $last_update) 0 0 0
Condition0%0/6
-f $img_bak and $last_update and $mtime >= $last_update
!ll&&!rl&&r
000
-f $img_bak and $last_update
!ll&&!rl&&r
000
MC/DC0%0/3
-f $img_bak and $last_update and $mtime >= $last_update
-f $img_bak $last_update $mtime >= $last_update
Truth table0%0/4
A and B and C
A= -f $img_bakB= $last_updateC= $mtime >= $last_update
ABCresult
0XX0
10X0
1100
1111
748 0 $self->log()->info("$img_bak has not changed ($mtime/$last_update), skipping\n");
749 0 $has_changed = 0;
750 0 next;
751 }
752 }
753
754 #
755
756 0 ▶ if (! -d $img_root) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $img_root) 0 0 0
757
758 0 $self->log()->info("create $img_root");
759
760 0 ▶ if (! mkpath([$img_root], 0, 0755)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (mkpath([$img_root], 0, 493)) 0 0 0
761 0 $self->log()->error("failed to create $img_root, $!");
762 0 next;
763 }
764 }
765
766 0 ▶ if (! getstore($source, $img_bak)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&getstore($source, $img_bak)) 0 0 0
767 0 $self->log()->error("failed to store '$source' as '$img_bak', $!\n");
768 0 next;
769 }
770
771 0 $self->log()->info("stored $img_bak");
772
773 #
774
775 0 $files_modified ++;
776 }
777  
778 #
779 # Ensure that we don't accidentally purge any metafiles
780 #
781  
782 0 my $meta_bak = $self->path_rdf_dumpfile($info);
783 0 push @{$self->{'_scrub'}->{$id}}, basename($meta_bak);
784  
785 #
786 # Do we need to keep going...
787 #
788  
789 0 ▶ $has_changed = ($files_modified) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$files_modified ? : 0 0 0
790  
791 0 $self->log()->info("has changed (filemod) : $has_changed");
792  
793 0 ▶ if ((! $has_changed) && (! $force)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_changed or $force) 0 0 0
Condition0%0/3
$has_changed or $force
l!l&&r!l&&!r
000
MC/DC0%0/2
$has_changed or $force
$has_changed $force
Truth table0%0/3
A or B
A= $has_changedB= $force
ABresult
1X1
011
000
794  
795 0 my $lastmod = $self->{'__lastmod_since'};
796 0 $self->log()->info("last mod : $lastmod");
797  
798 0 ▶ if (($lastmod) && ($last_update >= $lastmod)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastmod and $last_update >= $lastmod) 0 0 0
Condition0%0/3
$lastmod and $last_update >= $lastmod
!ll&&!rl&&r
000
MC/DC0%0/2
$lastmod and $last_update >= $lastmod
$lastmod $last_update >= $lastmod
Truth table0%0/3
A and B
A= $lastmodB= $last_update >= $lastmod
ABresult
0X0
100
111
799 0 $has_changed = 1;
800 0 $self->log()->info("has changed (update) : $has_changed ($last_update - $lastmod)");
801 }
802  
803 #
804 # Ensure the RDF file is there and up to date
805 #
806  
807 0 ▶ if (! $self->{cfg}->param("rdf.rdfdump_inline")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"cfg"}->param("rdf.rdfdump_inline")) 0 0 0
808
809 0 my $dump = $self->path_rdf_dumpfile($info);
810 0 $self->log()->info("test for rdf dump : $dump");
811  
812 0 ▶ if (($has_changed) && (-f $dump)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_changed and -f $dump) { } 0 0 0
Condition0%0/3
$has_changed and -f $dump
!ll&&!rl&&r
000
MC/DC0%0/2
$has_changed and -f $dump
$has_changed -f $dump
Truth table0%0/3
A and B
A= $has_changedB= -f $dump
ABresult
0X0
100
111
813  
814 0 my $dumpmod = (stat($dump))[9];
815 0 $self->log()->info("rdf dump : $dump");
816  
817 0 ▶ if ($dumpmod >= $lastmod) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumpmod >= $lastmod) 0 0 0
818 0 $has_changed = 0;
819 0 $self->log()->info("has changed (rdf) : $has_changed ($last_update - $dumpmod)");
820 }
821 }
822  
823 else {
824 0 ▶ if (! -f $dump) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $dump) 0 0 0
825 0 $self->log()->info("rdf dump does not exist : $dump");
826 0 $has_changed = 1;
827 }
828 }
829 }
830  
831 }
832  
833 0 $self->log()->info("has changed (final) : $has_changed");
834  
835 #
836 # Is that RDF in your pants?
837 #
838
839 0 ▶ if ($self->{cfg}->param("rdf.do_dump")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cfg"}->param("rdf.do_dump")) 0 0 0
840 0 $self->store_rdf($info, $has_changed, $force);
841 }
842  
843 #
844 # JPEG/IPTC
845 #
846  
847 0 ▶ if ($self->{cfg}->param("iptc.do_dump")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cfg"}->param("iptc.do_dump")) 0 0 0
848 0 $self->store_iptc($info, $has_changed, $force);
849 }
850  
851 0 return 1;
852 }
853  
854 sub store_rdf {
855 0 ▶ my $self = shift;
Subroutine store_rdf: not called CC=18 SCAR=58.3
Pod undocumented
856 0 my $photo = shift;
857 0 my $has_changed = shift;
858 0 my $force = shift;
859  
860 0 ▶ if (! $force){
Branch: 1 branch
BranchTrueFalseTotal
unless ($force) 0 0 0
861 0 $force = $self->{'cfg'}->param("rdf.force");
862 }
863  
864 0 my $rdf_root = $self->{cfg}->param("rdf.rdfdump_root");
865 0 my $rdf_inline = $self->{cfg}->param("rdf.rdfdump_inline");
866 0 my $rdf_str = "";
867  
868 0 ▶ if ((! $rdf_inline) && (! $rdf_root)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rdf_inline or $rdf_root) 0 0 0
Condition0%0/3
$rdf_inline or $rdf_root
l!l&&r!l&&!r
000
MC/DC0%0/2
$rdf_inline or $rdf_root
$rdf_inline $rdf_root
Truth table0%0/3
A or B
A= $rdf_inlineB= $rdf_root
ABresult
1X1
011
000
869 0 $rdf_root = $self->{cfg}->param("backup.photos_root");
870 }
871  
872 0 my $secret = $photo->find("/rsp/photo/\@originalsecret")->string_value();
873 0 my $id = $photo->find("/rsp/photo/\@id")->string_value();
874  
875 0 my $meta_bak = $self->path_rdf_dumpfile($photo);
876 0 my $meta_str = "";
877  
878 0 ▶ if ((! $force) && (! $has_changed) && (! $rdf_inline) && (-f $meta_bak)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $force || $has_changed || $rdf_inline and -f $meta_bak) 0 0 0
Condition0%0/9
not $force || $has_changed || $rdf_inline and -f $meta_bak
!ll&&!rl&&r
000
$force || $has_changed || $rdf_inline
l!l&&r!l&&!r
000
$force or $has_changed
l!l&&r!l&&!r
000
MC/DC0%0/4
not $force || $has_changed || $rdf_inline and -f $meta_bak
$force $has_changed $rdf_inline -f $meta_bak
Truth table0%0/5
not(A or B || C) and D
A= $forceB= $has_changedC= $rdf_inlineD= -f $meta_bak
ABCDresult
1XXX0
01XX0
001X0
00000
00011
879 0 return 1;
880 }
881
882 #
883 #
884 #
885  
886 0 my $meta_root = dirname($meta_bak);
887  
888 0 ▶ if ((! -d $meta_root) && (! $rdf_inline)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $meta_root or $rdf_inline) 0 0 0
Condition0%0/3
-d $meta_root or $rdf_inline
l!l&&r!l&&!r
000
MC/DC0%0/2
-d $meta_root or $rdf_inline
-d $meta_root $rdf_inline
Truth table0%0/3
A or B
A= -d $meta_rootB= $rdf_inline
ABresult
1X1
011
000
889
890 0 $self->log()->info("create $meta_root");
891
892 0 ▶ if (! mkpath([$meta_root], 0, 0755)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (mkpath([$meta_root], 0, 493)) 0 0 0
893 0 $self->log()->error("failed to create $meta_root, $!");
894 0 next;
895 }
896 }
897
898 #
899 #
900 #
901  
902 0 $self->log()->info("fetching RDF data for photo");
903
904 0 my $fh = undef;
905  
906 0 ▶ if ($rdf_inline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdf_inline) { } 0 0 0
907 0 $fh = IO::Scalar->new(\$rdf_str);
908 }
909  
910 else {
911 0 $fh = IO::AtomicFile->open($meta_bak, "w");
912 }
913  
914 0 ▶ if (! $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh) 0 0 0
915 0 $self->log()->error("failed to open '$meta_bak', $!");
916 0 return 0;
917 }
918
919 #
920 #
921 #
922  
923 0 my $desc_ok = $self->describe_photo({photo_id => $id,
924 secret => $secret,
925 fh => \*$fh});
926
927 0 ▶ if (! $desc_ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($desc_ok) 0 0 0
928 0 $self->log()->error("failed to describe photo $id:$secret\n");
929  
930 0 ▶ if (! $rdf_inline){
Branch: 1 branch
BranchTrueFalseTotal
unless ($rdf_inline) 0 0 0
931 0 $fh->delete();
932 }
933  
934 0 return 0;
935 }
936
937 #
938 # JPEG/RDF COM
939 #
940  
941 0 ▶ if ($rdf_inline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdf_inline) { } 0 0 0
942 0 ▶ if (! $self->store_rdf_inline(\$rdf_str, $self->{'__files'}->{'Original'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->store_rdf_inline(\$rdf_str, $self->{"__files"}{"Original"})) 0 0 0
943 0 return 0;
944 }
945 }
946  
947 else {
948 0 ▶ if (! $fh->close()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh->close) 0 0 0
949 0 $self->log()->error("failed to write '$meta_bak', $!");
950 0 return 0;
951 }
952 }
953  
954 0 return 1;
955 }
956  
957 sub store_iptc {
958 0 ▶ my $self = shift;
Subroutine store_iptc: not called CC=3 SCAR=24.8
Pod undocumented
959 0 my $photo = shift;
960 0 my $has_changed = shift;
961 0 my $force = shift;
962  
963 0 ▶ if ((! $has_changed) && (! $force)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_changed or $force) 0 0 0
Condition0%0/3
$has_changed or $force
l!l&&r!l&&!r
000
MC/DC0%0/2
$has_changed or $force
$has_changed $force
Truth table0%0/3
A or B
A= $has_changedB= $force
ABresult
1X1
011
000
964 0 return 1;
965 }
966  
967 0 return $self->store_iptc_inline($photo, $self->{'__files'}->{'Original'});
968 }
969  
970 sub store_iptc_inline {
971 0 ▶ my $self = shift;
Subroutine store_iptc_inline: not called CC=6 SCAR=37.4
Pod undocumented
972 0 my $photo = shift;
973 0 my $original = shift;
974  
975 0 my $im = $self->_jpeg_handler($original);
976  
977 0 ▶ if (! $im) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im) 0 0 0
978 0 return 0;
979 }
980  
981 0 my %iptc = ('Headline' => $self->_iptcify($photo->find("/rsp/photo/title")->string_value()),
982 'Caption/Abstract' => $self->_iptcify($photo->find("/rsp/photo/description")->string_value()),
983 'Keywords' => []);
984  
985 0 my @tags = ();
986  
987 0 foreach my $tag ($photo->findnodes("/rsp/photo/tags/tag")) {
988 0 my $raw = $self->_iptcify($tag->getAttribute("raw"));
989  
990 0 ▶ if ($raw =~ /\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw =~ /\s/) 0 0 0
991 0 $raw = "\"$raw\"";
992 }
993  
994 0 push @{$iptc{'Keywords'}}, $raw;
995 }
996  
997 0 ▶ if (! $im->set_app13_data(\%iptc, 'UPDATE', 'IPTC')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im->set_app13_data(\%iptc, "UPDATE", "IPTC")) 0 0 0
998 0 $self->log()->error("Failed to updated IPTC");
999 0 return 0;
1000 }
1001  
1002 0 ▶ if (! $im->save($original)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im->save($original)) 0 0 0
1003 0 $self->log()->error("Failed store IPTC, $!");
1004 0 return 0;
1005 }
1006  
1007 0 return 1;
1008 }
1009  
1010 sub store_rdf_inline {
1011 0 ▶ my $self = shift;
Subroutine store_rdf_inline: not called CC=3 SCAR=24.8
Pod undocumented
1012 0 my $str_rdf = shift;
1013 0 my $path_jpg = shift;
1014  
1015 0 my $im = $self->_jpeg_handler($path_jpg, "COM");
1016  
1017 0 ▶ if (! $im) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im) 0 0 0
1018 0 return 0;
1019 }
1020  
1021 0 $im->add_comment($$str_rdf);
1022  
1023 0 ▶ if (! $im->save("$path_jpg")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im->save("$path_jpg")) 0 0 0
1024 0 $self->log()->error("Failed store COM block, $!");
1025 0 return 0;
1026 }
1027  
1028 0 return 1;
1029 }
1030  
1031 =head2 $obj->scrub()
1032  
1033 Returns true or false.
1034  
1035 =cut
1036  
1037 sub scrub {
1038 0 ▶ my $self = shift;
Subroutine scrub: not called CC=7 SCAR=40.3
Pod documented
1039
1040 0 ▶ if (! keys %{$self->{'_scrub'}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"_scrub"};}) 0 0 0
1041 0 return 1;
1042 }
1043
1044 #
1045
1046 0 my $rule = File::Find::Rule->new();
1047 0 $rule->file();
1048
1049 $rule->exec(sub {
1050 0 ▶ my ($shortname, $path, $fullname) = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
1051
1052 # $self->log()->info("test $shortname");
1053
1054 0 $shortname =~ /^\d{8}-(\d+)-/;
1055 0 my $id = $1;
1056
1057 0 ▶ if (! $id) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($id) 0 0 0
1058 0 return 0;
1059 }
1060  
1061 0 ▶ if (! exists($self->{'_scrub'}->{$id})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_scrub"}{$id}) 0 0 0
1062 0 return 0;
1063 }
1064
1065 0 ▶ if (grep /$shortname/, @{$self->{'_scrub'}->{$id}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep /$shortname/, @{$$self{"_scrub"}{$id};}) 0 0 0
1066 0 return 0;
1067 }
1068
1069 0 $self->log()->info("mark $fullname for scrubbing");
1070 0 return 1;
1071 0 });
1072
1073 #
1074
1075 0 foreach my $root ($rule->in($self->{'cfg'}->param("backup.photos_root"))) {
1076
1077 0 $self->log()->info("unlink $root");
1078  
1079 0 ▶ if (! unlink($root)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (unlink $root) 0 0 0
1080 0 $self->log()->error("failed to unlink $root, $!");
1081 0 next;
1082 }
1083
1084 # next unlink empty parent directories
1085
1086 0 my $dd_dir = dirname($root);
1087 0 my $mm_dir = dirname($dd_dir);
1088 0 my $yyyy_dir = dirname($mm_dir);
1089
1090 0 foreach my $path ($dd_dir, $mm_dir, $yyyy_dir) {
1091 0 ▶ if (&_has_children($path)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_has_children($path)) { } 0 0 0
1092 0 last;
1093 }
1094
1095 else {
1096  
1097 0 $self->log()->info("unlink $path");
1098  
1099 0 ▶ if (! rmtree([$path], 0, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (rmtree([$path], 0, 1)) 0 0 0
1100 0 $self->log()->error("failed to unlink, $path");
1101 0 last;
1102 }
1103 }
1104 }
1105 }
1106
1107 #
1108
1109 0 $self->{'_scrub'} = {};
1110 0 return 1;
1111 }
1112  
1113 =head2 $obj->cancel_backup()
1114  
1115 Cancel the backup process as soon as the current photo backup
1116 is complete.
1117  
1118 =cut
1119  
1120 sub cancel_backup {
1121 0 ▶ my $self = shift;
Subroutine cancel_backup: not called CC=1 SCAR=6.9
Pod documented
1122 0 $self->{'__cancel'} = 1;
1123 }
1124  
1125 =head2 $obj->register_callback($name, \&func)
1126  
1127 B<This method is still considered experimental and may be removed.>
1128  
1129 Valid callback triggers are :
1130  
1131 =over 4
1132  
1133 =item * B<start_backup_queue>
1134  
1135 The list of photos to be backed up is pulled from the Flickr servers
1136 is done in batches. This trigger is invoked for the first successful
1137 result set.
1138  
1139 The callback function will be passed a I<XML::XPath> representation
1140 of the result document returned by the Flickr API.
1141  
1142 =item * B<finish_backup_queue>
1143  
1144 This trigger is invoked after the last photo has been backed up.
1145  
1146 =item * B<start_backup_photo>
1147  
1148 This trigger is invoked before the object's B<backup_photo> method is
1149 called.
1150  
1151 The callback function will be passed a I<XML::XPath> representation
1152 of the current photo, as returned by the Flickr API.
1153  
1154 =item * B<finish_backup_photo>
1155  
1156 This trigger is invoked after the object's B<backup_photo> method is
1157 called.
1158  
1159 The callback function will be passed a I<XML::XPath> representation
1160 of the current photo, as returned by the Flickr API, followed by a
1161 boolean indicating whether or not the backup was successful.
1162  
1163 =back
1164  
1165 Returns true or false, if I<$func> is not a valid code
1166 reference.
1167  
1168 =cut
1169  
1170 sub register_callback {
1171 0 ▶ my $self = shift;
Subroutine register_callback: not called CC=2 SCAR=17.9
Pod documented
1172 0 my $name = shift;
1173 0 my $func = shift;
1174  
1175 0 ▶ if (ref($func) ne "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $func ne "CODE") 0 0 0
1176 0 return 0;
1177 }
1178  
1179 0 $self->{'__callbacks'}->{$name} = $func;
1180 0 return 1;
1181 }
1182  
1183  
1184 =head2 $obj->namespaces()
1185  
1186 Returns a hash ref of the prefixes and namespaces used by I<Net::Flickr::RDF>
1187  
1188 The default key/value pairs are :
1189  
1190 =over 4
1191  
1192 =item B<a>
1193  
1194 http://www.w3.org/2000/10/annotation-ns
1195  
1196 =item B<acl>
1197  
1198 http://www.w3.org/2001/02/acls#
1199  
1200 =item B<dc>
1201  
1202 http://purl.org/dc/elements/1.1/
1203  
1204 =item B<dcterms>
1205  
1206 http://purl.org/dc/terms/
1207  
1208 =item B<exif>
1209  
1210 http://nwalsh.com/rdf/exif#
1211  
1212 =item B<exifi>
1213  
1214 http://nwalsh.com/rdf/exif-intrinsic#
1215  
1216 =item B<flickr>
1217  
1218 x-urn:flickr:
1219  
1220 =item B<foaf>
1221  
1222 http://xmlns.com/foaf/0.1/#
1223  
1224 =item B<geo>
1225  
1226 http://www.w3.org/2003/01/geo/wgs84_pos#
1227  
1228 =item B<i>
1229  
1230 http://www.w3.org/2004/02/image-regions#
1231  
1232 =item B<rdf>
1233  
1234 http://www.w3.org/1999/02/22-rdf-syntax-ns#
1235  
1236 =item B<rdfs>
1237  
1238 http://www.w3.org/2000/01/rdf-schema#
1239  
1240 =item B<skos>
1241  
1242 http://www.w3.org/2004/02/skos/core#
1243  
1244 =back
1245  
1246 I<Net::Flickr::Backup> adds the following namespaces :
1247  
1248 =over 4
1249  
1250 =item B<computer>
1251  
1252 x-urn:B<$OSNAME>: (where $OSNAME is the value of the English.pm
1253 $OSNAME variable.
1254  
1255 =back
1256  
1257 =cut
1258  
1259 sub namespaces {
1260 0 ▶ my $self = shift;
Subroutine namespaces: not called CC=2 SCAR=17.9
Pod documented
1261 0 my %ns = %{$self->SUPER::namespaces()};
1262 0 $ns{computer} = sprintf("x-urn:%s:",$OSNAME);
1263 0 ▶ return (wantarray) ? %ns : \%ns;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1264 }
1265  
1266 =head2 $obj->namespace_prefix($uri)
1267  
1268 Return the namespace prefix for I<$uri>
1269  
1270 =cut
1271  
1272 # Defined in Net::Flickr::RDF
1273  
1274 =head2 $obj->uri_shortform($prefix,$name)
1275  
1276 Returns a string in the form of I<prefix>:I<property>. The property is
1277 the value of $name. The prefix passed may or may be the same as the prefix
1278 returned depending on whether or not the user has defined or redefined their
1279 own list of namespaces.
1280  
1281 The prefix passed to the method is assumed to be one of prefixes in the
1282 B<default> list of namespaces.
1283  
1284 =cut
1285  
1286 # Defined in Net::Flickr::RDF
1287  
1288 =head2 $obj->make_photo_triples(\%data)
1289  
1290 Returns an array ref of array refs of the meta data associated with a
1291 photo (I<%data>).
1292  
1293 If any errors are unencounter an error is recorded via the B<log>
1294 method and the method returns undef.
1295  
1296 =cut
1297  
1298 sub make_photo_triples {
1299 0 ▶ my $self = shift;
Subroutine make_photo_triples: not called CC=3 SCAR=24.8
Pod documented
1300 0 my $data = shift;
1301
1302 0 my $triples = $self->SUPER::make_photo_triples($data);
1303
1304 0 ▶ if (! $triples) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($triples) 0 0 0
1305 0 return undef;
1306 }
1307
1308 0 my $user_id = (getpwuid($EUID))[0];
1309 0 my $os_uri = sprintf("x-urn:%s:",$OSNAME);
1310 0 my $user_uri = $os_uri."user";
1311
1312 0 my $creator_uri = sprintf("x-urn:%s#%s", $self->hostname_short(), $user_id);
1313
1314 0 push @$triples, [$user_uri, $self->uri_shortform("rdfs", "subClassOf"), "http://xmlns.com/foaf/0.1/Person"];
1315
1316 0 foreach my $label (keys %{$self->{'__files'}}) {
1317
1318 0 my $uri = "file://".$self->{'__files'}->{$label};
1319 0 my $photo = sprintf("%s%s/%s", $FLICKR_URL_PHOTOS, $data->{user_id}, $data->{photo_id});
1320
1321 0 push @$triples, [$uri, $self->uri_shortform("rdfs", "seeAlso"), $photo];
1322 0 push @$triples, [$uri, $self->uri_shortform("dc", "creator"), $creator_uri];
1323 0 push @$triples, [$uri, $self->uri_shortform("dcterms", "created"), &_w3cdtf()];
1324 }
1325
1326 0 push @$triples, [$creator_uri, $self->uri_shortform("foaf", "name"), (getpwuid($EUID))[6]];
1327 0 push @$triples, [$creator_uri, $self->uri_shortform("foaf", "nick"), $user_id];
1328 0 push @$triples, [$creator_uri, $self->uri_shortform("rdf", "type"), "computer:user"];
1329
1330 0 return $triples;
1331 }
1332  
1333 sub hostname_short {
1334 0 ▶ my $self = shift;
Subroutine hostname_short: not called CC=2 SCAR=17.9
Pod undocumented
1335  
1336 0 ▶ if ($self->{'__hostname'}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__hostname"}) 0 0 0
1337 0 return $self->{'__hostname'};
1338 }
1339  
1340 0 my @parts = split(/\./, hostname());
1341 0 my $short = $parts[0];
1342
1343 0 $self->{'__hostname'} = $short;
1344 0 return $short;
1345 }
1346  
1347 =head2 $obj->namespace_prefix($uri)
1348  
1349 Return the namespace prefix for I<$uri>
1350  
1351 =cut
1352  
1353 =head2 $obj->uri_shortform($prefix,$name)
1354  
1355 Returns a string in the form of I<prefix>:I<property>. The property is
1356 the value of $name. The prefix passed may or may be the same as the prefix
1357 returned depending on whether or not the user has defined or redefined their
1358 own list of namespaces.
1359  
1360 The prefix passed to the method is assumed to be one of prefixes in the
1361 B<default> list of namespaces.
1362  
1363 =cut
1364  
1365 # Defined in Net::Flickr::RDF
1366  
1367 =head2 $obj->api_call(\%args)
1368  
1369 Valid args are :
1370  
1371 =over 4
1372  
1373 =item * B<method>
1374  
1375 A string containing the name of the Flickr API method you are
1376 calling.
1377  
1378 =item * B<args>
1379  
1380 A hash ref containing the key value pairs you are passing to
1381 I<method>
1382  
1383 =back
1384  
1385 If the method encounters any errors calling the API, receives an API error
1386 or can not parse the response it will log an error event, via the B<log> method,
1387 and return undef.
1388  
1389 Otherwise it will return a I<XML::LibXML::Document> object (if XML::LibXML is
1390 installed) or a I<XML::XPath> object.
1391  
1392 =cut
1393  
1394 # Defined in Net::Flickr::API
1395  
1396 =head2 $obj->log()
1397  
1398 Returns a I<Log::Dispatch> object.
1399  
1400 =cut
1401  
1402 # Defined in Net::Flickr::API
1403  
1404 sub path_rdf_dumpfile {
1405 0 ▶ my $self = shift;
Subroutine path_rdf_dumpfile: not called CC=4 SCAR=30.0
Pod undocumented
1406 0 my $photo = shift;
1407  
1408 0 my $rdf_root = $self->{cfg}->param("rdf.rdfdump_root");
1409 0 my $rdf_inline = $self->{cfg}->param("rdf.rdfdump_inline");
1410 0 my $rdf_str = "";
1411  
1412 0 ▶ if ((! $rdf_inline) && (! $rdf_root)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rdf_inline or $rdf_root) 0 0 0
Condition0%0/3
$rdf_inline or $rdf_root
l!l&&r!l&&!r
000
MC/DC0%0/2
$rdf_inline or $rdf_root
$rdf_inline $rdf_root
Truth table0%0/3
A or B
A= $rdf_inlineB= $rdf_root
ABresult
1X1
011
000
1413 0 $rdf_root = $self->{cfg}->param("backup.photos_root");
1414 }
1415  
1416 0 my $id = $photo->find("/rsp/photo/\@id")->string_value();
1417 0 my $secret = $photo->find("/rsp/photo/\@secret")->string_value();
1418 0 ▶ my $title = $photo->find("/rsp/photo/title")->string_value() || "untitled";
Condition0%0/2
$photo->find('/rsp/photo/title')->string_value || 'untitled'
l!l
00
MC/DC0%0/1
$photo->find('/rsp/photo/title')->string_value || 'untitled'
$photo->find('/rsp/photo/title')->string_value
Truth table0%0/2
A
A= $photo->find('/rsp/photo/title')->string_value
Aresult
11
00
1419 0 $title = &_clean($title);
1420  
1421 0 my $dt = $photo->find("/rsp/photo/dates/\@taken")->string_value();
1422
1423 0 $dt =~ /^(\d{4})-(\d{2})-(\d{2})/;
1424 0 my ($yyyy,$mm,$dd) = ($1,$2,$3);
1425  
1426 0 my $meta_root = File::Spec->catdir($rdf_root, $yyyy, $mm, $dd);
1427 0 my $meta_fname = sprintf("%04d%02d%02d-%s-%s.xml", $yyyy, $mm, $dd, $id, $title);
1428 0 my $meta_path = File::Spec->catfile($meta_root, $meta_fname);
1429  
1430 0 return $meta_path;
1431 }
1432  
1433 sub _clean {
1434 0 ▶ my $str = shift;
Subroutine _clean: not called CC=1 SCAR=6.9
1435
1436 0 $str = lc($str);
1437
1438 0 $str =~ s/\.jpg$//;
1439
1440 # unidecode to convert everything to
1441 # happy happy ASCII
1442
1443 # see also : http://perladvent.org/2004/12th/
1444
1445 0 $str = unidecode(&_unescape(&_decode($str)));
1446
1447 0 $str =~ s/@/at/g;
1448 0 $str =~ s/&/and/g;
1449 0 $str =~ s/\*/star/g;
1450
1451 0 $str =~ s/[^a-z0-9-_]/ /ig;
1452 0 $str =~ s/'//g;
1453 0 $str =~ s/\^//g;
1454
1455 # make all whitespace single spaces
1456 0 $str =~ s/\s+/ /g;
1457
1458 # remove starting or trailing whitespace
1459 0 $str =~ s/^\s+//;
1460 0 $str =~ s/\s+$//;
1461  
1462 # remove trailing periods
1463 0 $str =~ s/\.+$//;
1464  
1465 # make all spaces underscores
1466 0 $str =~ s/ /_/g;
1467
1468 0 return $str;
1469 }
1470  
1471 sub _decode {
1472 0 ▶ my $str = shift;
Subroutine _decode: not called CC=2 SCAR=17.9
1473
1474 0 ▶ if (! utf8::is_utf8($str)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (utf8::is_utf8($str)) 0 0 0
1475 0 $str = decode_utf8($str);
1476 }
1477
1478 0 $str =~ s/(?:%([a-fA-F0-9]{2})%([a-fA-F0-9]{2}))/pack("U0U*", hex($1), hex($2))/eg;
1479 0 return $str;
1480 }
1481  
1482 # Borrowed from URI::Escape
1483  
1484 sub _unescape {
1485 0 ▶ my $str = shift;
Subroutine _unescape: not called CC=2 SCAR=17.9
1486
1487 0 ▶ if (defined($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $str) 0 0 0
1488 0 $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
1489 }
1490
1491 0 return $str;
1492 }
1493  
1494 sub _has_children {
1495 0 ▶ my $path = shift;
Subroutine _has_children: not called CC=1 SCAR=6.9
1496 0 my $dh = DirHandle->new($path);
1497 0 my $has = grep { $_ !~ /^\.+$/ } $dh->read();
1498 0 return $has;
1499 }
1500  
1501 # Borrowed from LWP::Authen::Wsse
1502  
1503 sub _w3cdtf {
1504 0 ▶ my ($sec, $min, $hour, $mday, $mon, $year) = gmtime();
Subroutine _w3cdtf: not called CC=1 SCAR=6.9
1505 0 $mon++; $year += 1900;
1506
1507 0 return sprintf("%04s-%02s-%02sT%02s:%02s:%02sZ",
1508 $year, $mon, $mday, $hour, $min, $sec);
1509 }
1510  
1511 sub _has_callback {
1512 0 ▶ my $self = shift;
Subroutine _has_callback: not called CC=3 SCAR=24.8
1513 0 my $name = shift;
1514  
1515 0 my $cb = $self->{'__callbacks'};
1516  
1517 0 ▶ if (! exists($cb->{$name})) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $cb->{$name}) { } 0 0 0
elsif (ref($cb->{$name} ne 'CODE')) { } 0 0 0
1518 0 return 0;
1519 }
1520  
1521 elsif (ref($cb->{$name} ne "CODE")) {
1522 0 return 0;
1523 }
1524  
1525 else {
1526 0 return 1;
1527 }
1528 }
1529  
1530 sub _execute_callback {
1531 0 ▶ my $self = shift;
Subroutine _execute_callback: not called CC=1 SCAR=6.9
1532 0 my $name = shift;
1533 0 $self->{'__callbacks'}->{$name}->(@_);
1534 }
1535  
1536 sub _mk_mindate {
1537 0 ▶ my $str = shift;
Subroutine _mk_mindate: not called CC=7 SCAR=40.3
1538
1539 0 $str =~ /^(\d+)([hdwM])$/;
1540
1541 0 my $count = $1;
1542 0 my $period = $2;
1543
1544 # print "count $count : period $period\n";
1545
1546 0 ▶ if ((! $count) || (! $period)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count and $period) 0 0 0
Condition0%0/3
$count and $period
!ll&&!rl&&r
000
MC/DC0%0/2
$count and $period
$count $period
Truth table0%0/3
A and B
A= $countB= $period
ABresult
0X0
100
111
1547 0 return 0;
1548 }
1549
1550 #
1551
1552 0 ▶ if ($period eq "h") {
Branch: 4 branches
BranchTrueFalseTotal
if ($period eq 'h') { } 0 0 0
elsif ($period eq 'd') { } 0 0 0
elsif ($period eq 'w') { } 0 0 0
elsif ($period eq 'M') { } 0 0 0
1553 0 return time() - ($count * (60 * 60));
1554 }
1555
1556 elsif ($period eq "d") {
1557 0 return time() - ($count * (24 * (60 * 60)));
1558 }
1559
1560 elsif ($period eq "w") {
1561 0 return time() - ($count * (7 * (24 * (60 * 60))));
1562 }
1563
1564 elsif ($period eq "M") {
1565 0 return time() - ($count * (4 * (7 * (24 * (60 * 60)))));
1566 }
1567
1568 else {
1569 0 return 0;
1570 }
1571 }
1572  
1573 sub _jpeg_handler {
1574 0 ▶ my $self = shift;
Subroutine _jpeg_handler: not called CC=3 SCAR=24.8
1575 0 my $img = shift;
1576  
1577 0 eval "require Image::MetaData::JPEG";
1578
1579 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1580 0 $self->log()->error("Failed to load Image::MetaData::JPEG, $@");
1581 0 return undef;
1582 }
1583  
1584 0 my $im = Image::MetaData::JPEG->new($img, @_);
1585  
1586 0 ▶ if (! $im) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($im) 0 0 0
1587 0 $self->log()->error("Failed to read $img, " . Image::MetaData::JPEG::Error());
1588 0 return undef;
1589 }
1590  
1591 0 return $im;
1592 }
1593  
1594 sub _iptcify {
1595 0 ▶ my $self = shift;
Subroutine _iptcify: not called CC=1 SCAR=6.9
1596 0 return encode("iso-8859-1", &_decode($_[0]));
1597 }
1598  
1599 =head1 EXAMPLES
1600  
1601 =cut
1602  
1603 =head2 CONFIG FILES
1604  
1605 This is an example of a Config::Simple file used to back up photos tagged
1606 with 'cameraphone' from Flickr
1607  
1608 [flickr]
1609 api_key=asd6234kjhdmbzcxi6e323
1610 api_secret=s00p3rs3k3t
1611 auth_token=123-omgwtf4u
1612 api_handler=LibXML
1613  
1614 [search]
1615 tags=cameraphone
1616 per_page=500
1617  
1618 [backup]
1619 photos_root=/home/asc/photos
1620 scrub_backups=1
1621 fetch_medium=1
1622 fetch_square=1
1623 force=0
1624  
1625 [rdf]
1626 do_dump=1
1627 rdfdump_root=/home/asc/photos
1628  
1629 =head2 RDF
1630  
1631 This is an example of an RDF dump for a photograph backed up from
1632 Flickr (using Net::Flickr::RDF) :
1633  
1634  
1635 <?xml version='1.0'?>
1636 <rdf:RDF
1637 xmlns:geoname="http://www.geonames.org/onto#"
1638 xmlns:a="http://www.w3.org/2000/10/annotation-ns"
1639 xmlns:ph="http://www.machinetags.org/wiki/ph#camera"
1640 xmlns:filtr="http://www.machinetags.org/wiki/filtr#process"
1641 xmlns:nfr_geo="http://www.machinetags.org/wiki/geo#debug"
1642 xmlns:place="x-urn:flickr:place:"
1643 xmlns:exif="http://nwalsh.com/rdf/exif#"
1644 xmlns:mt="x-urn:flickr:machinetag:"
1645 xmlns:exifi="http://nwalsh.com/rdf/exif-intrinsic#"
1646 xmlns:geonames="http://www.machinetags.org/wiki/geonames#feature"
1647 xmlns:dcterms="http://purl.org/dc/terms/"
1648 xmlns:dc="http://purl.org/dc/elements/1.1/"
1649 xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
1650 xmlns:acl="http://www.w3.org/2001/02/acls#"
1651 xmlns:skos="http://www.w3.org/2004/02/skos/core#"
1652 xmlns:foaf="http://xmlns.com/foaf/0.1/"
1653 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
1654 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
1655 xmlns:flickr="x-urn:flickr:"
1656 >
1657  
1658 <flickr:user rdf:about="http://www.flickr.com/people/72238590@N00">
1659 <foaf:mbox_sha1sum>2fc2c76d7634d1a6446b1898bf5471205ed3d0cb</foaf:mbox_sha1sum>
1660 <foaf:name></foaf:name>
1661 <foaf:nick>thincvox</foaf:nick>
1662 </flickr:user>
1663  
1664 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/filtr:process=filtr">
1665 <skos:altLabel>filtr</skos:altLabel>
1666 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1667 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/filtr:process=filtr"/>
1668 <skos:prefLabel rdf:resource="filtr:process=filtr"/>
1669 </flickr:tag>
1670  
1671 <geoname:Feature rdf:about="http://ws.geonames.org/rdf?geonameId=5400754">
1672 <geoname:featureCode>PPLX</geoname:featureCode>
1673 <geoname:countryCode>US</geoname:countryCode>
1674 <geoname:regionCode>CA</geoname:regionCode>
1675 <geoname:gtopo30>58</geoname:gtopo30>
1676 <geoname:region>State of California</geoname:region>
1677 <geoname:city>San Francisco County</geoname:city>
1678 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1679 </geoname:Feature>
1680  
1681 <flickr:machinetag rdf:about="http://www.machinetags.org/wiki/geonames#feature">
1682 <mt:predicate>feature</mt:predicate>
1683 <mt:namespace>geonames</mt:namespace>
1684 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1685 </flickr:machinetag>
1686  
1687 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg">
1688 <dcterms:relation>Original</dcterms:relation>
1689 <exifi:height>1944</exifi:height>
1690 <exifi:width>2592</exifi:width>
1691 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1692 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1693 </dcterms:StillImage>
1694  
1695 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/cameraphone">
1696 <skos:prefLabel>cameraphone</skos:prefLabel>
1697 </flickr:tag>
1698  
1699 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/filtr">
1700 <skos:prefLabel>filtr</skos:prefLabel>
1701 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1702 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/filtr"/>
1703 </flickr:tag>
1704  
1705 <rdf:Description rdf:about="http://www.flickr.com/photos/35034348999@N01/522214395#exif">
1706 <exif:flash>Flash did not fire, auto mode</exif:flash>
1707 <exif:digitalZoomRatio>100/100</exif:digitalZoomRatio>
1708 <exif:isoSpeedRatings>100</exif:isoSpeedRatings>
1709 <exif:pixelXDimension>2592</exif:pixelXDimension>
1710 <exif:apertureValue>297/100</exif:apertureValue>
1711 <exif:pixelYDimension>1944</exif:pixelYDimension>
1712 <exif:focalLength>5.6 mm</exif:focalLength>
1713 <exif:dateTimeDigitized>2007-05-30T15:10:01PDT</exif:dateTimeDigitized>
1714 <exif:colorSpace>sRGB</exif:colorSpace>
1715 <exif:fNumber>f/2.8</exif:fNumber>
1716 <exif:dateTimeOriginal>2007-05-30T15:10:01PDT</exif:dateTimeOriginal>
1717 <exif:shutterSpeedValue>4351/1000</exif:shutterSpeedValue>
1718 <exif:exposureTime>0.049 sec (49/1000)</exif:exposureTime>
1719 </rdf:Description>
1720  
1721 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/sanfrancisco">
1722 <skos:prefLabel>san francisco</skos:prefLabel>
1723 <skos:altLabel>sanfrancisco</skos:altLabel>
1724 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1725 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/sanfrancisco"/>
1726 </flickr:tag>
1727  
1728 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/sanfrancisco">
1729 <skos:prefLabel>sanfrancisco</skos:prefLabel>
1730 </flickr:tag>
1731  
1732 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_ed16f959a2.jpg">
1733 <dcterms:relation>Medium</dcterms:relation>
1734 <exifi:height>375</exifi:height>
1735 <exifi:width>500</exifi:width>
1736 <dcterms:isVersionOf rdf:resource="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg"/>
1737 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1738 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1739 </dcterms:StillImage>
1740  
1741 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/geonames:feature=5405296">
1742 <skos:altLabel>5405296</skos:altLabel>
1743 <skos:broader rdf:resource="http://www.machinetags.org/wiki/geonames#feature"/>
1744 <skos:prefLabel rdf:resource="geonames:feature=5405296"/>
1745 </flickr:tag>
1746  
1747 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/cameraphone">
1748 <skos:prefLabel>cameraphone</skos:prefLabel>
1749 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1750 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/cameraphone"/>
1751 </flickr:tag>
1752  
1753 <flickr:photoset rdf:about="http://www.flickr.com/photos/35034348999@N01/sets/72157594459261101">
1754 <dc:description></dc:description>
1755 <dc:title>LOG (2007)</dc:title>
1756 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1757 </flickr:photoset>
1758  
1759 <flickr:comment rdf:about="http://www.flickr.com/photos/straup/522214395/#comment72157600293655654">
1760 <dc:identifier>6065-522214395-72157600293655654</dc:identifier>
1761 <dc:created>2007-05-31T14:54:25</dc:created>
1762 <a:body>Kittens!</a:body>
1763 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1764 <a:annotates rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1765 </flickr:comment>
1766  
1767 <flickr:user rdf:about="http://www.flickr.com/people/35034348999@N01">
1768 <foaf:mbox_sha1sum>587a68f90c4030a9b0c7d8ca6ff8549a8b40e5cd</foaf:mbox_sha1sum>
1769 <foaf:name>Aaron Straup Cope</foaf:name>
1770 <foaf:nick>straup</foaf:nick>
1771 </flickr:user>
1772  
1773 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/ph:camera=n95">
1774 <skos:altLabel>n95</skos:altLabel>
1775 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1776 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/ph:camera=n95"/>
1777 <skos:prefLabel rdf:resource="ph:camera=n95"/>
1778 </flickr:tag>
1779  
1780 <rdf:Description rdf:about="x-urn:flickr:comment">
1781 <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/10/annotation-nsAnnotation"/>
1782 </rdf:Description>
1783  
1784 <flickr:comment rdf:about="http://www.flickr.com/photos/straup/522214395/#comment72157600295486776">
1785 <dc:identifier>6065-522214395-72157600295486776</dc:identifier>
1786 <dc:created>2007-06-01T00:19:05</dc:created>
1787 <a:body>here kitty, kitty, &lt;a href=&quot;http://thincvox.com/audio_recordings/meow.mp3&quot;&gt;meow&lt;/a&gt;</a:body>
1788 <dc:creator rdf:resource="http://www.flickr.com/people/72238590@N00"/>
1789 <a:annotates rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1790 </flickr:comment>
1791  
1792 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/geonames:feature=5405296">
1793 <skos:altLabel>5405296</skos:altLabel>
1794 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1795 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/geonames:feature=5405296"/>
1796 <skos:prefLabel rdf:resource="geonames:feature=5405296"/>
1797 </flickr:tag>
1798  
1799 <flickr:machinetag rdf:about="http://www.machinetags.org/wiki/filtr#process">
1800 <mt:predicate>process</mt:predicate>
1801 <mt:namespace>filtr</mt:namespace>
1802 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1803 </flickr:machinetag>
1804  
1805 <flickr:machinetag rdf:about="http://www.machinetags.org/wiki/geo#debug">
1806 <mt:predicate>debug</mt:predicate>
1807 <mt:namespace>geo</mt:namespace>
1808 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1809 </flickr:machinetag>
1810  
1811 <flickr:photo rdf:about="http://www.flickr.com/photos/35034348999@N01/522214395">
1812 <filtr:process>filtr</filtr:process>
1813 <nfr_geo:debug>namespace test</nfr_geo:debug>
1814 <acl:access>visbility</acl:access>
1815 <dc:title>Untitled #1180563722</dc:title>
1816 <ph:camera>n95</ph:camera>
1817 <dc:rights>All rights reserved.</dc:rights>
1818 <acl:accessor>public</acl:accessor>
1819 <dc:description></dc:description>
1820 <dc:created>2007-05-30T15:10:01-0700</dc:created>
1821 <dc:dateSubmitted>2007-05-30T15:18:39-0700</dc:dateSubmitted>
1822 <geonames:feature>5405296</geonames:feature>
1823 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1824 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/sanfrancisco"/>
1825 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/ph:camera=n95"/>
1826 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/geonames:feature=5405296"/>
1827 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/geo:debug=namespacetest"/>
1828 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/filtr:process=filtr"/>
1829 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/filtr"/>
1830 <dc:subject rdf:resource="http://www.flickr.com/photos/35034348999@N01/tags/cameraphone"/>
1831 <dcterms:isPartOf rdf:resource="http://www.flickr.com/photos/35034348999@N01/sets/72157594459261101"/>
1832 <a:hasAnnotation rdf:resource="http://www.flickr.com/photos/straup/522214395/#comment72157600295486776"/>
1833 <a:hasAnnotation rdf:resource="http://www.flickr.com/photos/straup/522214395/#comment72157600293655654"/>
1834 <geo:Point rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#location"/>
1835 </flickr:photo>
1836  
1837 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_ed16f959a2_t.jpg">
1838 <dcterms:relation>Thumbnail</dcterms:relation>
1839 <exifi:height>75</exifi:height>
1840 <exifi:width>100</exifi:width>
1841 <dcterms:isVersionOf rdf:resource="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg"/>
1842 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1843 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1844 </dcterms:StillImage>
1845  
1846 <rdf:Description rdf:about="x-urn:flickr:machinetag">
1847 <rdfs:subClassOf rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
1848 </rdf:Description>
1849  
1850 <geo:Point rdf:about="http://www.flickr.com/photos/35034348999@N01/522214395#location">
1851 <geo:long>-122.401937</geo:long>
1852 <acl:access>visbility</acl:access>
1853 <geo:lat>37.794694</geo:lat>
1854 <flickr:accuracy>16</flickr:accuracy>
1855 <acl:accessor>public</acl:accessor>
1856 <skos:broader rdf:resource="http://ws.geonames.org/rdf?geonameId=5400754"/>
1857 <skos:broader rdf:resource="http://www.flickr.com/geo/United%20States/California/San%20Francisco/San%20Francisco"/>
1858 </geo:Point>
1859  
1860 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/filtr:process=filtr">
1861 <skos:altLabel>filtr</skos:altLabel>
1862 <skos:broader rdf:resource="http://www.machinetags.org/wiki/filtr#process"/>
1863 <skos:prefLabel rdf:resource="filtr:process=filtr"/>
1864 </flickr:tag>
1865  
1866 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/ph:camera=n95">
1867 <skos:altLabel>n95</skos:altLabel>
1868 <skos:broader rdf:resource="http://www.machinetags.org/wiki/ph#camera"/>
1869 <skos:prefLabel rdf:resource="ph:camera=n95"/>
1870 </flickr:tag>
1871  
1872 <rdf:Description rdf:about="#">
1873 <dcterms:hasVersion>2.0:1180823550</dcterms:hasVersion>
1874 <dc:created>2007-06-02T15:32:30-0700</dc:created>
1875 <dc:creator rdf:resource="http://search.cpan.org/dist/Net-Flickr-RDF-2.0"/>
1876 <a:annotates rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1877 </rdf:Description>
1878  
1879 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/filtr">
1880 <skos:prefLabel>filtr</skos:prefLabel>
1881 </flickr:tag>
1882  
1883 <flickr:tag rdf:about="http://www.flickr.com/photos/35034348999@N01/tags/geo:debug=namespacetest">
1884 <skos:altLabel>namespace test</skos:altLabel>
1885 <dc:creator rdf:resource="http://www.flickr.com/people/35034348999@N01"/>
1886 <skos:broader rdf:resource="http://www.flickr.com/photos/tags/geo:debug=namespacetest"/>
1887 <skos:prefLabel rdf:resource="geo:debug=namespace test"/>
1888 <skos:altLabel rdf:resource="geo:debug=namespacetest"/>
1889 </flickr:tag>
1890  
1891 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_ed16f959a2_m.jpg">
1892 <dcterms:relation>Small</dcterms:relation>
1893 <exifi:height>180</exifi:height>
1894 <exifi:width>240</exifi:width>
1895 <dcterms:isVersionOf rdf:resource="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg"/>
1896 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1897 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1898 </dcterms:StillImage>
1899  
1900 <rdf:Description rdf:about="x-urn:flickr:user">
1901 <rdfs:subClassOf rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
1902 </rdf:Description>
1903  
1904 <flickr:machinetag rdf:about="http://www.machinetags.org/wiki/ph#camera">
1905 <mt:predicate>camera</mt:predicate>
1906 <mt:namespace>ph</mt:namespace>
1907 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1908 </flickr:machinetag>
1909  
1910 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_ed16f959a2_s.jpg">
1911 <dcterms:relation>Square</dcterms:relation>
1912 <exifi:height>75</exifi:height>
1913 <exifi:width>75</exifi:width>
1914 <dcterms:isVersionOf rdf:resource="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg"/>
1915 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1916 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1917 </dcterms:StillImage>
1918  
1919 <dcterms:StillImage rdf:about="http://farm1.static.flickr.com/232/522214395_ed16f959a2_b.jpg">
1920 <dcterms:relation>Large</dcterms:relation>
1921 <exifi:height>768</exifi:height>
1922 <exifi:width>1024</exifi:width>
1923 <dcterms:isVersionOf rdf:resource="http://farm1.static.flickr.com/232/522214395_d2841bdbb0_o.jpg"/>
1924 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1925 <rdfs:seeAlso rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395#exif"/>
1926 </dcterms:StillImage>
1927  
1928 <flickr:place rdf:about="http://www.flickr.com/geo/United%20States/California/San%20Francisco/San%20Francisco">
1929 <place:county>San Francisco</place:county>
1930 <place:country>United States</place:country>
1931 <place:region>California</place:region>
1932 <place:locality>San Francisco</place:locality>
1933 <dc:isReferencedBy rdf:resource="http://www.flickr.com/photos/35034348999@N01/522214395"/>
1934 </flickr:place>
1935  
1936 <flickr:tag rdf:about="http://www.flickr.com/photos/tags/geo:debug=namespacetest">
1937 <skos:altLabel>namespace test</skos:altLabel>
1938 <skos:broader rdf:resource="http://www.machinetags.org/wiki/geo#debug"/>
1939 <skos:prefLabel rdf:resource="geo:debug=namespacetest"/>
1940 </flickr:tag>
1941  
1942 </rdf:RDF>
1943  
1944 =head1 VERSION
1945  
1946 3.1
1947  
1948 =head1 DATE
1949  
1950 $Date: 2010/12/19 19:06:56 $
1951  
1952 =head1 AUTHOR
1953  
1954 Aaron Straup Cope E<lt>ascope@cpan.orgE<gt>
1955  
1956 =head1 CONTRIBUTORS
1957  
1958 Thomas Sibley E<lt>tsibley@cpan.orgE<gt>
1959  
1960 =head1 SEE ALSO
1961  
1962 L<Net::Flickr::API>
1963  
1964 L<Net::Flickr::RDF>
1965  
1966 L<Config::Simple>
1967  
1968 http://www.flickr.com/services/api/misc.userauth.html
1969  
1970 =head1 BUGS
1971  
1972 Please report all bugs via http://rt.cpan.org
1973  
1974 =head1 LICENSE
1975  
1976 Copyright (c) 2005-2008 Aaron Straup Cope. All Rights Reserved.
1977  
1978 This is free software. You may redistribute it and/or
1979 modify it under the same terms as Perl itself.
1980  
1981 =cut
1982  
1983 1 return 1;
↑ Summary Build »