This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflickr-diff.pl
115 lines (81 loc) · 2.22 KB
/
flickr-diff.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /usr/bin/perl
# find photos not uploaded to flickr
use warnings;
use strict;
use Getopt::Long;
use IO::File;
use Pod::Usage;
my $pkg = 'flickr-diff';
my $version = '0.2';
# process command line
my $multiply;
if (!&GetOptions(help => sub { &pod2usage(-exitval => 0) },
multiply => \$multiply,
version => sub { print "$pkg $version\n"; exit 0 }))
{
warn("Try ``$pkg --help'' for more information.\n");
exit(1);
}
# read uploaded photos from flickr-upload-set log
my $fus = 'flickr-upload-set';
my $log = "$ENV{HOME}/$fus/$fus.done";
my $done_fh = IO::File->new("<$log");
if (!defined($done_fh)) {
warn("$pkg: failed to open done file: $!");
exit(1);
}
my %done;
while (defined(my $line = $done_fh->getline)) {
chomp($line);
++$done{$line};
}
$done_fh->close;
if ($multiply) {
# find multiple uploads
foreach my $upload (sort(keys(%done))) {
if ($done{$upload} > 1) {
print("$upload\t$done{$upload}\n");
}
}
exit(0);
}
# loop through photos
my @photos = glob("$ENV{HOME}/Pictures/iPhoto\\\ Library/Originals/*/*/*");
foreach my $photo (@photos) {
if (!exists($done{$photo})) {
print "$photo\n";
}
}
exit(0);
__END__
=pod
=head1 NAME
flickr-diff - identify photos not uploaded and multiply uploaded
=head1 SYNOPSIS
B<flickr-diff> [OPTIONS]...
=head1 DESCRIPTION
This program compares the original files in a user's iPhoto library with
the list of files in the flickr-upload-set.done log. It is also able to
identify photos that have been uploaded more than once.
=head1 OPTIONS
If an argument to a long option is mandatory, it is also mandatory for
the corresponding short option; the same is true for optional arguments.
=over 4
=item -h, --help
Display a brief description and listing of all available options.
=item -m, --multiply
Report photos uploaded more than once and the number of times uploaded
rather than the photos not yet uploaded.
=item -v, --version
Output version information and exit.
=item --
Terminate option processing. This option is useful when file names
begin with a dash (-).
=back
=head1 BUGS
No known bugs.
=head1 SEE ALSO
flickr-upload-set(1)
=head1 AUTHOR
David Dooling <[email protected]>
=cut