line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::VideoHost::Video::Storage; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$App::VideoHost::Video::Storage::VERSION = '0.143310'; # TRIAL |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Manage a list of L<App::VideoHost::Video>s |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
256
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::Spec; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use App::VideoHost::Video; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Carp qw/croak/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'directory' => ( is => 'rw' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub check_errors { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @errors; |
21
|
|
|
|
|
|
|
foreach my $video ($self->list) { |
22
|
|
|
|
|
|
|
eval |
23
|
|
|
|
|
|
|
{ $video->check; 1; } |
24
|
|
|
|
|
|
|
or do { |
25
|
|
|
|
|
|
|
my $error = $@; |
26
|
|
|
|
|
|
|
chomp $error; |
27
|
|
|
|
|
|
|
push @errors, $video->directory . ": $error"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
return @errors; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub video_dirs { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $dir = $self->directory; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "no directory provided" unless $dir; |
38
|
|
|
|
|
|
|
croak "directory $dir does not exist" unless -d $self->directory; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @potential_dirs = glob File::Spec->catdir($dir, "*"); |
41
|
|
|
|
|
|
|
my @dirs; |
42
|
|
|
|
|
|
|
foreach (@potential_dirs) { |
43
|
|
|
|
|
|
|
next if /^\./; |
44
|
|
|
|
|
|
|
next if ! -d; |
45
|
|
|
|
|
|
|
push @dirs, $_; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return @dirs; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub list { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
return reverse sort { $a->metadata('date') cmp $b->metadata('date') } |
54
|
|
|
|
|
|
|
map { App::VideoHost::Video->new(directory => $_) } |
55
|
|
|
|
|
|
|
$self->video_dirs; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub find_by_short_name { |
59
|
|
|
|
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
my $title = shift; |
61
|
|
|
|
|
|
|
foreach ($self->list) { |
62
|
|
|
|
|
|
|
if ($title eq $_->short_name) { |
63
|
|
|
|
|
|
|
return $_; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
return; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
App::VideoHost::Video::Storage - Manage a list of L<App::VideoHost::Video>s |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.143310 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Justin Hawkins <justin@eatmorecode.com> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Justin Hawkins. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
95
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |