-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmreader
More file actions
executable file
·118 lines (83 loc) · 2.57 KB
/
mreader
File metadata and controls
executable file
·118 lines (83 loc) · 2.57 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env perl
BEGIN {
if ((exists $ENV{MUTATE_HOME}) and (-d $ENV{MUTATE_HOME})) {
system "$ENV{MUTATE_HOME}/mbootstrap";
}
else {
die
"You must set MUTATE_HOME to the directory where Mutate is located.\n";
}
}
use 5.018_000;
use strict;
use warnings;
no if $] >= 5.018, warnings => "experimental::smartmatch";
no if $] >= 5.018, warnings => "experimental::lexical_subs";
use Getopt::Long qw/:config no_ignore_case /;
use Pod::Usage;
use File::Find;
use File::Basename;
use Mojo::JSON;
my %obj;
GetOptions(
'help|?|h' => \$obj{options}->{'help'},
'preset|p=s' => \$obj{options}->{'preset'},
'event|e' => \$obj{options}->{'event'},
);
pod2usage "\nmreader, Distributed A/V Media Reader\n"
if defined $obj{options}->{help}
or not $ARGV[0];
unless (defined $obj{options}->{preset}) {
$obj{options}->{preset} = 'normal';
}
if (not defined $obj{options}->{'event'}) {
find(\&process, @ARGV);
sub process {
if ($File::Find::name
=~ /\.(mp2|mp3|mp4|mkv|mov|avi|wmv|webm|ogg|flv|vob)$/x)
{
my @crop_detect;
say $File::Find::name;
open my $mplayer,
"mplayer \"$_\" -include $ENV{MUTATE_HOME}/presets/mreader.$obj{options}->{preset} "
. " -profile $obj{options}->{preset} 2> /tmp/.mutate/mreader.err |";
for (<$mplayer>) {
when (/\w+:=(.*)/x) {
say "\t" . lc($1) . " = $2";
}
when (/ID_(\w+)=(.*)/x) {
say "\t" . lc($1) . " = $2";
}
when (/ID_(\w+)_(\w+)=(.*)/x) {
say "\t" . lc("$1 $2") . " = $3";
}
when (/.*crop=(\d+:\d+:\d+:\d+)/x) {
push @crop_detect, $1;
}
}
if (scalar @crop_detect > 1) {
say "\tcrop = " . $crop_detect[-1];
}
close $mplayer;
}
}
}
else {
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
my $tx =
$ua->get("https://localhost:8443/mreader" => {DNT => 1} => json =>
{arguments => "@ARGV"});
say $tx->res->body;
}
exit(0);
__END__
=head1 SYNOPSIS
</directory/to/scan> [options]
Options:
-h, -?, --help This help / usage screen...
-p, --preset Type 'mpresets mwriter' for a complete list of presets.
-e, --event Submit this invocation to Mutate's Event Loop.
-o, --output Future: Format console output as JSON, YAML, XML
Example: mreader ~/Videos/movie.mp4
=cut