-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
lsrel
executable file
·104 lines (65 loc) · 1.86 KB
/
lsrel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/perl
# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2:
# abstract: list scene releases on a fs based on media type
use strict;
use warnings FATAL => 'all';
use vars qw($VERSION);
use autodie qw(:all);
#no warnings 'experimental::smartmatch';
use File::Media::Sort qw(media_sort);
use Getopt::Long;
use Pod::Usage;
use File::Basename;
use Cwd;
use Data::Dumper;
use File::PatternMatch qw(patternmatch);
my $opt_type;
GetOptions(
'type:s' => \$opt_type,
'h|help' => sub { pod2usage(verbose => 1); exit; },
);
die "Please specify a type with -t\n", unless defined $opt_type;
my $directory = shift // getcwd();
my @results = map { basename($_); } media_sort($opt_type, glob("$directory/*"));
my $pm = patternmatch(256, @results);
for my $k(sort(keys(%{ $pm }))) {
for my $media(sort(keys(%{ $pm->{$k} }))) {
printf "%s [%-15s]\n", $media, $pm->{$k}->{$media};
}
}
__END__
=pod
=head1 NAME
lsrel - list scene releases on a fs based on media type
=head1 USAGE
lsrel [OPTIONS] DIRECTORY
=head1 DESCRIPTION
lsrel takes a list of filenames and returns a list of filenames based on type.
Type can be:
- music
- tv
- mvid
=head1 OPTIONS
-t, --type request files matching type
-v, --verbose explain what is being done
-h, --help show this help and exit
=head1 REPORTING BUGS
Report bugs and/or feature requests on L<https://github.com/trapd00r/lsrel>,
the repository issue tracker or directly to L<[email protected]>
=head1 AUTHOR
Magnus Woldrich
CPAN ID: WOLDRICH
http://japh.se
http://github.com/trapd00r
=head1 CONTRIBUTORS
None required yet.
=head1 COPYRIGHT
Copyright 2018 B<THIS APPLICATION>s L</AUTHOR> and L</CONTRIBUTORS> as listed
above.
=head1 LICENSE
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<~/|http://japh.se>
=cut