line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::MediaMosa; |
2
|
1
|
|
|
1
|
|
50349
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
124363
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
1043
|
use Catmandu::MediaMosa; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Moo; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.279'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has base_url => (is => 'ro' , required => 1); |
11
|
|
|
|
|
|
|
has user => (is => 'ro' , required => 1); |
12
|
|
|
|
|
|
|
has password => (is => 'ro' , required => 1); |
13
|
|
|
|
|
|
|
has mm => (is => 'ro' , init_arg => undef , lazy => 1 , builder => '_build_mm'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _build_mm { |
16
|
|
|
|
|
|
|
my ($self) = @_; |
17
|
|
|
|
|
|
|
Catmandu::MediaMosa->new(base_url => $self->base_url , user => $self->user , password => $self->password); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generator { |
21
|
|
|
|
|
|
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub { |
24
|
|
|
|
|
|
|
state $offset = 0; |
25
|
|
|
|
|
|
|
state $res = []; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if (@{$res} == 0) { |
28
|
|
|
|
|
|
|
my $vpcore = $self->mm->asset_list({ offset => $offset , limit => 10 }); |
29
|
|
|
|
|
|
|
return undef unless defined $vpcore; |
30
|
|
|
|
|
|
|
my $hits = $vpcore->header->item_count_total; |
31
|
|
|
|
|
|
|
my $count = $vpcore->header->item_count; |
32
|
|
|
|
|
|
|
$res = $vpcore->items->to_array; |
33
|
|
|
|
|
|
|
$offset += $count; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $asset = shift @{$res}; |
37
|
|
|
|
|
|
|
return undef unless $asset; |
38
|
|
|
|
|
|
|
$self->mm->asset($asset)->items->first |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Catmandu::Importer::MediaMosa - Package that imports MediaMosa asset information into your application |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use Catmandu::Importer::MediaMosa; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $importer = Catmandu::Importer::MediaMosa->new(base_url => '...' , user => '...' , password => '...' ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $n = $importer->each(sub { |
53
|
|
|
|
|
|
|
my $hashref = $_[0]; |
54
|
|
|
|
|
|
|
# ... |
55
|
|
|
|
|
|
|
}); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 new(query => '...') |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Create a new MediaMosa importer using a query as input. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 count |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 each(&callback) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 ... |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The |
70
|
|
|
|
|
|
|
Catmandu::Importer::MediaMosa methods are not idempotent: MediaMosa feeds can only be read once. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SEE ALSO |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Patrick Hochstenbach C<< Patrick Hochstenbach at UGent be >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |