| 1 | package File::Media::Sort; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 3 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use vars qw($VERSION @ISA @EXPORT_OK); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | $VERSION = '0.068'; | |||||||||
| 9 | 3 | @ISA = qw(Exporter); | |||||||||
| 10 | |||||||||||
| 11 | 3 | @EXPORT_OK = qw( | |||||||||
| 12 | media_sort | ||||||||||
| 13 | ); | ||||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 3 | 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 | 3 | ▶ | sub media_sort { | ||||||||
|
Subroutine
media_sort: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 33 | 3 | my $type = shift; | |||||||||
| 34 | 3 | ▶ | die "Type not supported\n" unless exists($media_re{$type}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 3 | my @files = @_; | |||||||||
| 36 | |||||||||||
| 37 | 3 | my @results; | |||||||||
| 38 | 3 | for my $file(@files) { | |||||||||
| 39 | 3 | ▶ | if($file =~ m/$media_re{$type}->{regex}/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 3 | push(@results, $file); | |||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | 3 | return @results; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | 3 | 1; | |||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||