| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::VideoHost::Video::Storage; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$App::VideoHost::Video::Storage::VERSION = '0.143300'; # TRIAL |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
243
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use File::Spec; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use App::VideoHost::Video; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Carp qw/croak/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'directory' => ( is => 'rw' ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub check_errors { |
|
16
|
|
|
|
|
|
|
my $self = shift; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @errors; |
|
19
|
|
|
|
|
|
|
foreach my $video ($self->list) { |
|
20
|
|
|
|
|
|
|
eval |
|
21
|
|
|
|
|
|
|
{ $video->check; 1; } |
|
22
|
|
|
|
|
|
|
or do { |
|
23
|
|
|
|
|
|
|
my $error = $@; |
|
24
|
|
|
|
|
|
|
chomp $error; |
|
25
|
|
|
|
|
|
|
push @errors, $video->directory . ": $error"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
return @errors; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub video_dirs { |
|
32
|
|
|
|
|
|
|
my $self = shift; |
|
33
|
|
|
|
|
|
|
my $dir = $self->directory; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
croak "no directory provided" unless $dir; |
|
36
|
|
|
|
|
|
|
croak "directory $dir does not exist" unless -d $self->directory; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my @potential_dirs = glob File::Spec->catdir($dir, "*"); |
|
39
|
|
|
|
|
|
|
my @dirs; |
|
40
|
|
|
|
|
|
|
foreach (@potential_dirs) { |
|
41
|
|
|
|
|
|
|
next if /^\./; |
|
42
|
|
|
|
|
|
|
next if ! -d; |
|
43
|
|
|
|
|
|
|
push @dirs, $_; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return @dirs; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub list { |
|
50
|
|
|
|
|
|
|
my $self = shift; |
|
51
|
|
|
|
|
|
|
return reverse sort { $a->metadata('date') cmp $b->metadata('date') } |
|
52
|
|
|
|
|
|
|
map { App::VideoHost::Video->new(directory => $_) } |
|
53
|
|
|
|
|
|
|
$self->video_dirs; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub find_by_short_name { |
|
57
|
|
|
|
|
|
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
my $title = shift; |
|
59
|
|
|
|
|
|
|
foreach ($self->list) { |
|
60
|
|
|
|
|
|
|
if ($title eq $_->short_name) { |
|
61
|
|
|
|
|
|
|
return $_; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
return; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |