line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Media::Sort; |
2
|
2
|
|
|
2
|
|
134639
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
70
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
5
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
6
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION @ISA @EXPORT_OK); |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
206
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
6
|
$VERSION = '0.064'; |
9
|
2
|
|
|
|
|
40
|
@ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
349
|
@EXPORT_OK = qw( |
12
|
|
|
|
|
|
|
media_sort |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %media_re = ( |
17
|
|
|
|
|
|
|
tv => { |
18
|
|
|
|
|
|
|
regex => '(?i)([S0-9]+)?([E0-9]+)(.*TV)', |
19
|
|
|
|
|
|
|
# location => \@episodes, |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
mvid => { |
22
|
|
|
|
|
|
|
regex => '.*([_-]+)x264-[0-9]{4}', |
23
|
|
|
|
|
|
|
# location => \@mvids, |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
music => { |
26
|
|
|
|
|
|
|
regex => '.+(?:-|_-_)\w+-(?:[0-9]+CD?-)?(?:[0-9]{4}-)?(?:\w+)?', |
27
|
|
|
|
|
|
|
# location => \@music, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub media_sort { |
33
|
3
|
|
|
3
|
1
|
87
|
my $type = shift; |
34
|
3
|
50
|
|
|
|
10
|
die "Type not supported\n" unless exists($media_re{$type}); |
35
|
3
|
|
|
|
|
7
|
my @files = @_; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
5
|
my @results; |
38
|
3
|
|
|
|
|
6
|
for my $file(@files) { |
39
|
3
|
50
|
|
|
|
109
|
if($file =~ m/$media_re{$type}->{regex}/) { |
40
|
3
|
|
|
|
|
12
|
push(@results, $file); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
3
|
|
|
|
|
19
|
return @results; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |