| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Filename::Media::Info; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
496637
|
use 5.010001; |
|
|
1
|
|
|
|
|
5
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
21
|
|
|
|
1
|
|
|
|
|
104
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
50
|
|
|
8
|
1
|
|
|
1
|
|
636
|
use Time::Local qw(timelocal_posix); |
|
|
1
|
|
|
|
|
2503
|
|
|
|
1
|
|
|
|
|
873
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
11
|
|
|
|
|
|
|
our $DATE = '2025-08-23'; # DATE |
|
12
|
|
|
|
|
|
|
our $DIST = 'Filename-Media-Info'; # DIST |
|
13
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(parse_media_filename); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %SPEC; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$SPEC{parse_media_filename} = { |
|
20
|
|
|
|
|
|
|
v => 1.1, |
|
21
|
|
|
|
|
|
|
summary => 'Extract various information from media filenames', |
|
22
|
|
|
|
|
|
|
description => <<'MARKDOWN', |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
MARKDOWN |
|
26
|
|
|
|
|
|
|
args => { |
|
27
|
|
|
|
|
|
|
filename => { |
|
28
|
|
|
|
|
|
|
schema => 'filename*', |
|
29
|
|
|
|
|
|
|
req => 1, |
|
30
|
|
|
|
|
|
|
pos => 0, |
|
31
|
|
|
|
|
|
|
}, |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
result_naked => 1, |
|
34
|
|
|
|
|
|
|
result => { |
|
35
|
|
|
|
|
|
|
schema => ['hash*'], |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
examples => [ |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
args => {filename => 'IMG-20140828-WA0002.jpg'}, |
|
40
|
|
|
|
|
|
|
test => 0, |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
args => {filename => 'IMG_20141103_122548680_HDR.jpg'}, |
|
44
|
|
|
|
|
|
|
test => 0, |
|
45
|
|
|
|
|
|
|
}, |
|
46
|
|
|
|
|
|
|
], |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
sub parse_media_filename { |
|
49
|
0
|
|
|
0
|
1
|
|
my %args = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $filename = $args{filename}; |
|
52
|
0
|
|
|
|
|
|
my $res = {filename => $filename}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ($filename =~ /^Screenshot/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$res->{type} = 'image'; |
|
56
|
0
|
|
|
|
|
|
$res->{is_screenshot} = 1; |
|
57
|
|
|
|
|
|
|
} elsif ($filename =~ /^(IMG)[_-]/) { |
|
58
|
0
|
|
|
|
|
|
$res->{type} = 'image'; |
|
59
|
|
|
|
|
|
|
} elsif ($filename =~ /^(VID)[_-]/) { |
|
60
|
0
|
|
|
|
|
|
$res->{type} = 'video'; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($filename =~ /^(?:IMG|VID)_(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})(\d{3})?/) { |
|
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$res->{ymd} = "$1$2$3"; |
|
65
|
0
|
|
|
|
|
|
$res->{hms} = "$4$5$6"; |
|
66
|
0
|
|
|
|
|
|
$res->{millisecond} = $7; |
|
67
|
0
|
|
|
|
|
|
$res->{epoch} = timelocal_posix($6, $5, $4, $3, $2-1, $1-1900); |
|
68
|
|
|
|
|
|
|
} elsif ($filename =~ /^(?:IMG|VID)-(\d{4})(\d{2})(\d{2})-WA/) { |
|
69
|
0
|
|
|
|
|
|
$res->{ymd} = "$1$2$3"; |
|
70
|
0
|
|
|
|
|
|
$res->{hms} = "000000"; |
|
71
|
0
|
|
|
|
|
|
$res->{epoch} = timelocal_posix(0, 0, 0, $3, $2-1, $1-1900); |
|
72
|
0
|
|
|
|
|
|
$res->{is_whatsapp} = 1; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$res; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
# ABSTRACT: Extract various information from media filenames |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |