line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2008 Behan Webster. All rights reserved. This program is free |
2
|
|
|
|
|
|
|
# software; you can redistribute it and/or modify it under the same terms |
3
|
|
|
|
|
|
|
# as Perl itself. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Video::Filename; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
23593
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
793
|
use Debug::Simple; |
|
1
|
|
|
|
|
22369
|
|
|
1
|
|
|
|
|
73
|
|
11
|
1
|
|
|
1
|
|
9
|
use Data::Dumper; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
61
|
|
12
|
1
|
|
|
1
|
|
6
|
use Term::ANSIColor qw(:constants); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
336
|
|
13
|
1
|
|
|
1
|
|
859
|
use Text::Roman qw(roman2int); |
|
1
|
|
|
|
|
1190
|
|
|
1
|
|
|
|
|
61
|
|
14
|
|
|
|
|
|
|
$Term::ANSIColor::AUTORESET = 1; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @filePatterns @testFuncs); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1225
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = "0.35"; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@filePatterns = ( |
21
|
|
|
|
|
|
|
{ # DVD Episode Support - DddEee |
22
|
|
|
|
|
|
|
# Perl > v5.10 |
23
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]+)?(?:d|dvd|disc|disk)[\s._]?(?\d{1,2})[x\/\s._-]*(?:e|ep|episode)[\s._]?(?\d{1,2}(?:\.\d{1,2})?)(?:-?(?:(?:e|ep)[\s._]*)?(?\d{1,2}))?(?:[\s._]?(?:p|part)[\s._]?(?\d+))?(?[a-z])?(?:[\/\s._-]*(?[^\/]+?))?$', |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Perl < v5.10 |
26
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]+)?(?:d|dvd|disc|disk)[\s._]?(\d{1,2})[x\/\s._-]*(?:e|ep|episode)[\s._]?(\d{1,2})(?:-?(?:(?:e|ep)[\s._]*)?(\d{1,2}(?:\.\d{1,2})?))?(?:[\s._]?(?:p|part)[\s._]?(\d+))?([a-z])?(?:[\/\s._-]*([^\/]+?))?$', |
27
|
|
|
|
|
|
|
keys_compat => [qw(name dvd episode endep part subep epname)], |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
test_funcs => [1, 0, 1, 0], # DVD TV Episode Movie |
30
|
|
|
|
|
|
|
test_keys => [qw(filename name dvd episode endep part subep epname ext)], |
31
|
|
|
|
|
|
|
test_files => [ |
32
|
|
|
|
|
|
|
['D01E02.Episode_name.avi', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
33
|
|
|
|
|
|
|
['Series Name.D01E02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
34
|
|
|
|
|
|
|
['Series Name/D01E02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
35
|
|
|
|
|
|
|
['Series Name/D01E02/Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
36
|
|
|
|
|
|
|
['Series Name.D01E02a.Episode_name.avi', 'Series Name', 1, 2, undef, undef, 'a', 'Episode_name', 'avi'], |
37
|
|
|
|
|
|
|
['Series Name.D01E02p4.Episode_name.avi', 'Series Name', 1, 2, undef, 4, undef, 'Episode_name', 'avi'], |
38
|
|
|
|
|
|
|
['Series Name.D01E02-03.Episode_name.avi', 'Series Name', 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
39
|
|
|
|
|
|
|
['Series Name.D01E02-E03.Episode_name.avi', 'Series Name', 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
40
|
|
|
|
|
|
|
['Series Name.D01E02E.03.Episode_name.avi', 'Series Name', 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
41
|
|
|
|
|
|
|
['Series Name/D01E02E03/Episode_name.avi', 'Series Name', 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
42
|
|
|
|
|
|
|
['D01E02E03/Episode name.avi', undef, 1, 2, 3, undef, undef, 'Episode name', 'avi'], |
43
|
|
|
|
|
|
|
['Series Name.DVD_01.Episode_02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
44
|
|
|
|
|
|
|
['Series Name.disk_V.Episode_XI.Episode_name.avi', 'Series Name', 5, 11, undef, undef, undef, 'Episode_name', 'avi'], |
45
|
|
|
|
|
|
|
['Series Name.disc_V.Episode_XI.Part.XXV.Episode_name.avi', 'Series Name', 5, 11, undef, 25, undef, 'Episode_name', 'avi'], |
46
|
|
|
|
|
|
|
['Series Name.DVD01.Ep02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
47
|
|
|
|
|
|
|
['Series Name/dvd_01.Episode_02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
48
|
|
|
|
|
|
|
['Series Name/disk_01/Episode_02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
49
|
|
|
|
|
|
|
['Series Name/D.I/Ep02.Episode_name.avi', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
50
|
|
|
|
|
|
|
['Series Name/D three/Ep five Episode_name.avi', 'Series Name', 3, 5, undef, undef, undef, 'Episode_name', 'avi'], |
51
|
|
|
|
|
|
|
], |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
{ # TV Show Support - SssEee or Season_ss_Episode_ss |
54
|
|
|
|
|
|
|
# Perl > v5.10 |
55
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]+)?(?:s|se|season|series)[\s._-]?(?\d{1,2})[x\/\s._-]*(?:e|ep|episode|[\/\s._-]+)[\s._-]?(?\d{1,2})(?:-?(?:(?:e|ep)[\s._]*)?(?\d{1,2}))?(?:[\s._]?(?:p|part)[\s._]?(?\d+))?(?[a-z])?(?:[\/\s._-]*(?[^\/]+?))?$', |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Perl < v5.10 |
58
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]+)?(?:s|se|season|series)[\s._-]?(\d{1,2})[x\/\s._-]*(?:e|ep|episode|[\/\s._-]+)[\s._-]?(\d{1,2})(?:-?(?:(?:e|ep)[\s._]*)?(\d{1,2}))?(?:[\s._]?(?:p|part)[\s._]?(\d+))?([a-z])?(?:[\/\s._-]*([^\/]+?))?$', |
59
|
|
|
|
|
|
|
keys_compat => [qw(name season episode endep part subep epname)], |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
test_funcs => [0, 1, 1, 0], # DVD TV Episode Movie |
62
|
|
|
|
|
|
|
test_keys => [qw(filename name guess-name season episode endep part subep epname ext)], |
63
|
|
|
|
|
|
|
test_files => [ |
64
|
|
|
|
|
|
|
['S01E02.Episode_name.avi', undef, undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
65
|
|
|
|
|
|
|
['Series Name.S01E02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
66
|
|
|
|
|
|
|
['Series Name/S01E02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
67
|
|
|
|
|
|
|
['Series Name/S01E02/Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
68
|
|
|
|
|
|
|
['Series/Name/S01E02/Episode_name.avi', 'Name', 'Series Name', 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
69
|
|
|
|
|
|
|
['Series Name.S01E02a.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, 'a', 'Episode_name', 'avi'], |
70
|
|
|
|
|
|
|
['Series Name.S01E02p4.Episode_name.avi', 'Series Name', undef, 1, 2, undef, 4, undef, 'Episode_name', 'avi'], |
71
|
|
|
|
|
|
|
['Series Name.S01E02-03.Episode_name.avi', 'Series Name', undef, 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
72
|
|
|
|
|
|
|
['Series Name.S01E02-E03.Episode_name.avi', 'Series Name', undef, 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
73
|
|
|
|
|
|
|
['Series Name.S01E02E.03.Episode_name.avi', 'Series Name', undef, 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
74
|
|
|
|
|
|
|
['Series Name/S01E02E03/Episode_name.avi', 'Series Name', undef, 1, 2, 3, undef, undef, 'Episode_name', 'avi'], |
75
|
|
|
|
|
|
|
['S01E02E03/Episode name.avi', undef, undef, 1, 2, 3, undef, undef, 'Episode name', 'avi'], |
76
|
|
|
|
|
|
|
['Series Name.Season_01.Episode_02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
77
|
|
|
|
|
|
|
['Series Name.Season_V.Episode_XI.Episode_name.avi', 'Series Name', undef, 5, 11, undef, undef, undef, 'Episode_name', 'avi'], |
78
|
|
|
|
|
|
|
['Series Name.Season_V.Episode_XI.Part.XXV.Episode_name.avi', 'Series Name', undef, 5, 11, undef, 25, undef, 'Episode_name', 'avi'], |
79
|
|
|
|
|
|
|
['Series Name.Se01.Ep02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
80
|
|
|
|
|
|
|
['Series Name/Season_01.Episode_02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
81
|
|
|
|
|
|
|
['Series Name/Season_01/Episode_02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
82
|
|
|
|
|
|
|
['Series Name/Season_01/02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
83
|
|
|
|
|
|
|
['Series Name/S.I/Ep02.Episode_name.avi', 'Series Name', undef, 1, 2, undef, undef, undef, 'Episode_name', 'avi'], |
84
|
|
|
|
|
|
|
['Series Name/S.one/Ep twelve.Episode_name.avi', 'Series Name', undef, 1, 12, undef, undef, undef, 'Episode_name', 'avi'], |
85
|
|
|
|
|
|
|
], |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
{ # Movie IMDB Support |
88
|
|
|
|
|
|
|
# Perl > v5.10 |
89
|
|
|
|
|
|
|
re => '^(?.*?)?(?:[\/\s._-]*(?\[)?(?(?:19|20)\d{2})(?()\]))?(?:[\/\s._-]*(?\[)?(?:(?:imdb|tt)[\s._-]*)*(?\d{7})(?()\]))(?:[\s._-]*(?[^\/]+?))?$', |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Perl < v5.10 |
92
|
|
|
|
|
|
|
re_compat => '^(.*?)?(?:[\/\s._-]*\[?((?:19|20)\d{2})\]?)?(?:[\/\s._-]*\[?(?:(?:imdb|tt)[\s._-]*)*(\d{7})\]?)(?:[\s._-]*([^\/]+?))?$', |
93
|
|
|
|
|
|
|
keys_compat => [qw(movie year imdb title)], |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
test_funcs => [0, 0, 0, 1], # DVD TV Episode Movie |
96
|
|
|
|
|
|
|
test_keys => [qw(filename movie guess-movie year imdb title ext)], |
97
|
|
|
|
|
|
|
test_files => [ |
98
|
|
|
|
|
|
|
['Movie Name [1996] [imdb 1234567].mkv', 'Movie Name', undef, 1996, 1234567, undef, 'mkv'], |
99
|
|
|
|
|
|
|
['Movie Name [1996] [imdb tt1234567].mkv', 'Movie Name', undef, 1996, 1234567, undef, 'mkv'], |
100
|
|
|
|
|
|
|
['Movie Name [1996] [1234567].avi', 'Movie Name', undef, 1996, 1234567, undef, 'avi'], |
101
|
|
|
|
|
|
|
['Movie Name [1996] [tt1234567] foo.avi', 'Movie Name', undef, 1996, 1234567, 'foo', 'avi'], |
102
|
|
|
|
|
|
|
['Movie Name [1996]/tt1234567-foo.avi', 'Movie Name', undef, 1996, 1234567, 'foo', 'avi'], |
103
|
|
|
|
|
|
|
['Movie/Name/tt1234567_foo.avi', 'Name', 'Movie Name', undef, 1234567, 'foo', 'avi'], |
104
|
|
|
|
|
|
|
['Movie Name.[tt0096657] bar.avi', 'Movie Name', undef, undef, '0096657', 'bar', 'avi'], |
105
|
|
|
|
|
|
|
['Movie Name.tt0096657-foo.avi', 'Movie Name', undef, undef, '0096657', 'foo', 'avi'], |
106
|
|
|
|
|
|
|
['Movie.Name.tt0096657foo.avi', 'Movie.Name', undef, undef, '0096657', 'foo', 'avi'], |
107
|
|
|
|
|
|
|
['Movie Name.tt0096657_foo.avi', 'Movie Name', undef, undef, '0096657', 'foo', 'avi'], |
108
|
|
|
|
|
|
|
['Movie Name.tt0096657.avi', 'Movie Name', undef, undef, '0096657', undef, 'avi'], |
109
|
|
|
|
|
|
|
['Movie Name.[0096657].avi', 'Movie Name', undef, undef, '0096657', undef, 'avi'], |
110
|
|
|
|
|
|
|
['imdb-tt0096657.avi', undef, undef, undef, '0096657', undef, 'avi'], |
111
|
|
|
|
|
|
|
['tt0096657.mov', undef, undef, undef, '0096657', undef, 'mov'], |
112
|
|
|
|
|
|
|
['tt0096857', undef, undef, undef, '0096857', undef, undef], |
113
|
|
|
|
|
|
|
['1234576', undef, undef, undef, '1234576', undef, undef], |
114
|
|
|
|
|
|
|
], |
115
|
|
|
|
|
|
|
#warning => 'Found year instead of season+episode', |
116
|
|
|
|
|
|
|
}, |
117
|
|
|
|
|
|
|
{ # Movie + Year Support |
118
|
|
|
|
|
|
|
# Perl > v5.10 |
119
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]*)?(?\[)?(?(?:19|20)\d{2})(?()\])(?:[\s._-]*(?[^\/]+?))?$', |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Perl < v5.10 |
122
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]*)?\[?((?:19|20)\d{2})\]?(?:[\s._-]*([^\/]+?))?$', |
123
|
|
|
|
|
|
|
keys_compat => [qw(movie year title)], |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
test_funcs => [0, 0, 0, 1], # DVD TV Episode Movie |
126
|
|
|
|
|
|
|
test_keys => [qw(filename movie year title ext)], |
127
|
|
|
|
|
|
|
test_files => [ |
128
|
|
|
|
|
|
|
['Movie.[1988].avi', 'Movie', 1988, undef, 'avi'], |
129
|
|
|
|
|
|
|
['Movie.2000.title.avi', 'Movie', 2000, 'title', 'avi'], |
130
|
|
|
|
|
|
|
['Movie/2009.title.avi', 'Movie', 2009, 'title', 'avi'], |
131
|
|
|
|
|
|
|
], |
132
|
|
|
|
|
|
|
#warning => 'Found year instead of season+episode', |
133
|
|
|
|
|
|
|
}, |
134
|
|
|
|
|
|
|
{ # TV Show Support - see |
135
|
|
|
|
|
|
|
# Perl > v5.10 |
136
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]*)?(?\d{1,2}?)(?\d{2})(?:[\s._-]*(?.+?))?$', |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Perl < v5.10 |
139
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]*)?(\d{1,2}?)(\d{2})(?:[\s._-]*(.+?))?$', |
140
|
|
|
|
|
|
|
keys_compat => [qw(name season episode epname)], |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
test_funcs => [0, 1, 1, 0], # DVD TV Episode Movie |
143
|
|
|
|
|
|
|
test_keys => [qw(filename name season episode epname ext)], |
144
|
|
|
|
|
|
|
test_files => [ |
145
|
|
|
|
|
|
|
['SN102.Episode_name.avi', 'SN', 1, 2, 'Episode_name', 'avi'], |
146
|
|
|
|
|
|
|
['Series Name.102.Episode_name.avi', 'Series Name', 1, 2, 'Episode_name', 'avi'], |
147
|
|
|
|
|
|
|
['Series Name/102.Episode_name.avi', 'Series Name', 1, 2, 'Episode_name', 'avi'], |
148
|
|
|
|
|
|
|
], |
149
|
|
|
|
|
|
|
}, |
150
|
|
|
|
|
|
|
{ # TV Show Support - sxee |
151
|
|
|
|
|
|
|
# Perl > v5.10 |
152
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]*)?(?\[)?(?\d{1,2})[x\/](?\d{1,2})(?:-(?:\kx)?(?\d{1,2}))?(?()\])(?:[\s._-]*(?[^\/]+?))?$', |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Perl < v5.10 |
155
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]*)?\[?(\d{1,2})[x\/](\d{1,2})(?:-(?:\d{1,2}x)?(\d{1,2}))?\]?(?:[\s._-]*([^\/]+?))?$', |
156
|
|
|
|
|
|
|
keys_compat => [qw(name season episode endep epname)], |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
test_funcs => [0, 1, 1, 0], # DVD TV Episode Movie |
159
|
|
|
|
|
|
|
test_keys => [qw(filename name season episode endep epname ext)], |
160
|
|
|
|
|
|
|
test_files => [ |
161
|
|
|
|
|
|
|
['Series Name.1x02.Episode_name.avi', 'Series Name', 1, 2, undef, 'Episode_name', 'avi'], |
162
|
|
|
|
|
|
|
['Series Name/1x02.Episode_name.avi', 'Series Name', 1, 2, undef, 'Episode_name', 'avi'], |
163
|
|
|
|
|
|
|
['Series Name.[1x02].Episode_name.avi', 'Series Name', 1, 2, undef, 'Episode_name', 'avi'], |
164
|
|
|
|
|
|
|
['Series Name.1x02-03.Episode_name.avi', 'Series Name', 1, 2, 3, 'Episode_name', 'avi'], |
165
|
|
|
|
|
|
|
['Series Name.1x02-1x03.Episode_name.avi', 'Series Name', 1, 2, 3, 'Episode_name', 'avi'], |
166
|
|
|
|
|
|
|
], |
167
|
|
|
|
|
|
|
}, |
168
|
|
|
|
|
|
|
{ # TV Show Support - season only |
169
|
|
|
|
|
|
|
# Perl > v5.10 |
170
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]+)?(?:s|se|season|series)[\s._]?(?\d{1,2})(?:[\/\s._-]*(?[^\/]+?))?$', |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# Perl < v5.10 |
173
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]+)?(?:s|se|season|series)[\s._]?(\d{1,2})(?:[\/\s._-]*([^\/]+?))?$', |
174
|
|
|
|
|
|
|
keys_compat => [qw(name season epname)], |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
test_funcs => [0, 0, 0, 0], # DVD TV Episode Movie |
177
|
|
|
|
|
|
|
test_keys => [qw(filename name season epname ext)], |
178
|
|
|
|
|
|
|
test_files => [ |
179
|
|
|
|
|
|
|
['Series Name.s1.Episode_name.avi', 'Series Name', 1, 'Episode_name', 'avi'], |
180
|
|
|
|
|
|
|
['Series Name.s01.Episode_name.avi', 'Series Name', 1, 'Episode_name', 'avi'], |
181
|
|
|
|
|
|
|
['Series Name/se01.Episode_name.avi', 'Series Name', 1, 'Episode_name', 'avi'], |
182
|
|
|
|
|
|
|
['Series Name.season_1.Episode_name.avi', 'Series Name', 1, 'Episode_name', 'avi'], |
183
|
|
|
|
|
|
|
['Series Name/season_1/Episode_name.avi', 'Series Name', 1, 'Episode_name', 'avi'], |
184
|
|
|
|
|
|
|
['Series Name/season ten/Episode_name.avi', 'Series Name', 10, 'Episode_name', 'avi'], |
185
|
|
|
|
|
|
|
], |
186
|
|
|
|
|
|
|
}, |
187
|
|
|
|
|
|
|
{ # TV Show Support - episode only |
188
|
|
|
|
|
|
|
# Perl > v5.10 |
189
|
|
|
|
|
|
|
re => '^(?:(?.*?)[\/\s._-]*)?(?:(?:e|ep|episode)[\s._]?)?(?\d{1,2})(?:-(?:e|ep)?(?\d{1,2}))?(?:(?:p|part)(?\d+))?(?[a-z])?(?:[\/\s._-]*(?[^\/]+?))?$', |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# Perl < v5.10 |
192
|
|
|
|
|
|
|
re_compat => '^(?:(.*?)[\/\s._-]*)?(?:(?:e|ep|episode)[\s._]?)?(\d{1,2})(?:-(?:e|ep)?(\d{1,2}))?(?:(?:p|part)(\d+))?([a-z])?(?:[\/\s._-]*([^\/]+?))?$', |
193
|
|
|
|
|
|
|
keys_compat => [qw(name episode endep part subep epname)], |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
test_funcs => [0, 0, 1, 0], # DVD TV Episode Movie |
196
|
|
|
|
|
|
|
test_keys => [qw(filename name episode endep part subep epname ext)], |
197
|
|
|
|
|
|
|
test_files => [ |
198
|
|
|
|
|
|
|
['Series Name.Episode_02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
199
|
|
|
|
|
|
|
['Series Name/Episode_02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
200
|
|
|
|
|
|
|
['Series Name/Ep02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
201
|
|
|
|
|
|
|
['E02.Episode_name.avi', undef, 2, undef, undef, undef, 'Episode_name', 'avi'], |
202
|
|
|
|
|
|
|
['Series Name.E02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
203
|
|
|
|
|
|
|
['Series Name.02.Episode_name.avi', 'Series Nam', 2, undef, undef, undef, 'Episode_name', 'avi'], |
204
|
|
|
|
|
|
|
['Series Name/E02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
205
|
|
|
|
|
|
|
['Series Name/02.Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
206
|
|
|
|
|
|
|
['Series Name/E02/Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
207
|
|
|
|
|
|
|
['Series Name/02/Episode_name.avi', 'Series Name', 2, undef, undef, undef, 'Episode_name', 'avi'], |
208
|
|
|
|
|
|
|
['Series Name.E02a.Episode_name.avi', 'Series Name', 2, undef, undef, 'a', 'Episode_name', 'avi'], |
209
|
|
|
|
|
|
|
['Series Name.E02p3.Episode_name.avi', 'Series Name', 2, undef, 3, undef, 'Episode_name', 'avi'], |
210
|
|
|
|
|
|
|
['Series Name.E02-03.Episode_name.avi', 'Series Name', 2, 3, undef, undef, 'Episode_name', 'avi'], |
211
|
|
|
|
|
|
|
['Series Name.E02-E03.Episode_name.avi', 'Series Name', 2, 3, undef, undef, 'Episode_name', 'avi'], |
212
|
|
|
|
|
|
|
], |
213
|
|
|
|
|
|
|
}, |
214
|
|
|
|
|
|
|
{ # Default Movie Support |
215
|
|
|
|
|
|
|
# Perl > v5.10 |
216
|
|
|
|
|
|
|
re => '^(?.*)$', |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Perl < v5.10 |
219
|
|
|
|
|
|
|
re_compat => '^(.*)$', |
220
|
|
|
|
|
|
|
keys_compat => [qw(movie)], |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
test_funcs => [0, 0, 0, 1], # DVD TV Episode Movie |
223
|
|
|
|
|
|
|
test_keys => [qw(filename movie ext)], |
224
|
|
|
|
|
|
|
test_files => [ |
225
|
|
|
|
|
|
|
['Movie.mov', 'Movie', 'mov'], |
226
|
|
|
|
|
|
|
], |
227
|
|
|
|
|
|
|
#warning => 'Found year instead of season+episode', |
228
|
|
|
|
|
|
|
}, |
229
|
|
|
|
|
|
|
); |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
############################################################################### |
232
|
|
|
|
|
|
|
sub new { |
233
|
0
|
|
|
0
|
1
|
|
my $self = bless {}; |
234
|
|
|
|
|
|
|
# Read default values |
235
|
0
|
|
|
|
|
|
for my $key (qw(file name season episode part options)) { |
236
|
0
|
0
|
|
|
|
|
last unless defined $_[0]; |
237
|
0
|
0
|
|
|
|
|
if (ref $_[0]) { |
238
|
|
|
|
|
|
|
# Use a hashref for values |
239
|
0
|
|
|
|
|
|
while (my ($key, $value) = each %{$_[0]}) { |
|
0
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
$self->{$key} = $value; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
} else { |
243
|
0
|
|
|
|
|
|
$self->{$key} = shift; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
# Seed endep/subep from passed in episode |
247
|
0
|
0
|
|
|
|
|
if (defined $self->{episode}) { |
248
|
0
|
0
|
|
|
|
|
$self->{endep} = $1 if $self->{episode} =~ s/-(\d+)//i; |
249
|
0
|
0
|
|
|
|
|
$self->{subep} = $1 if $self->{episode} =~ s/([a-z])$//i; |
250
|
|
|
|
|
|
|
} |
251
|
0
|
|
|
|
|
|
&debug(5, "VideoFilename: $self->{file}\n"); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# Start parsing file |
254
|
0
|
|
|
|
|
|
my $file = $self->{file}; |
255
|
0
|
0
|
|
|
|
|
$self->{dir} = $1 if $file =~ m|^(.*/)|; |
256
|
0
|
0
|
|
|
|
|
$self->{filename} = $1 if $file; |
257
|
0
|
0
|
|
|
|
|
$self->{ext} = lc $1 if $file =~ s/\.([0-9a-z]+)$//i; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Translate appropriate roman/english numbers to numerals |
260
|
0
|
|
|
|
|
|
my $prefix = '(?:d|dvd|disc|disk|s|se|season|e|ep|episode)[\s._-]+'; |
261
|
0
|
|
|
|
|
|
my $end = '(?:day|part)[\s._-]+'; |
262
|
0
|
|
|
|
|
|
$file = &_allroman2int($file, $prefix, $end); |
263
|
0
|
|
|
|
|
|
$file = &_allnum2int($file, $prefix, $end); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# Run pre-processed filename through list of patterns |
266
|
0
|
|
|
|
|
|
for my $pat (@filePatterns) { |
267
|
0
|
0
|
|
|
|
|
if ($] >= 5.010000) { |
268
|
0
|
0
|
|
|
|
|
if ($file =~ /$pat->{re}/i) { |
269
|
0
|
0
|
|
|
|
|
&warning($pat->{warning}) if defined $pat->{warning}; |
270
|
0
|
|
|
|
|
|
&debug(3, "PARSEINFO: $pat->{re}\n"); |
271
|
0
|
|
|
|
|
|
$self->{regex} = $pat->{re}; |
272
|
1
|
|
|
1
|
|
1006
|
while (my ($key, $data) = each %-) { |
|
1
|
|
|
|
|
530
|
|
|
1
|
|
|
|
|
1970
|
|
|
0
|
|
|
|
|
|
|
273
|
0
|
0
|
0
|
|
|
|
$self->{$key} = $data->[0] if defined $data->[0] && !defined $self->{$key}; |
274
|
|
|
|
|
|
|
} |
275
|
0
|
|
|
|
|
|
last; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
} else { # No named groups in regexes |
278
|
0
|
|
|
|
|
|
my @matches; |
279
|
0
|
0
|
|
|
|
|
if (@matches = ($file =~ /$pat->{re_compat}/i)) { |
280
|
|
|
|
|
|
|
#print "MACTHES: ".join(',', @matches)."\n"; |
281
|
0
|
0
|
|
|
|
|
&warning($pat->{warning}) if defined $pat->{warning}; |
282
|
0
|
|
|
|
|
|
&debug(3, "PARSEINFO: $pat->{re_compat}\n"); |
283
|
0
|
|
|
|
|
|
$self->{regex} = $pat->{re_compat}; |
284
|
0
|
|
|
|
|
|
my $count = 0; |
285
|
0
|
|
|
|
|
|
foreach my $key (@{$pat->{keys_compat}}) { |
|
0
|
|
|
|
|
|
|
286
|
0
|
0
|
|
|
|
|
$self->{$key} = $matches[$count] unless defined $self->{$key}; |
287
|
0
|
|
|
|
|
|
$count++; |
288
|
|
|
|
|
|
|
} |
289
|
0
|
|
|
|
|
|
last; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# Perhaps a movie is really a name with default season or episode |
295
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{name} || defined $self->{season} || defined $self->{episode}) && defined $self->{movie}) { |
|
|
|
0
|
|
|
|
|
296
|
0
|
0
|
|
|
|
|
$self->{name} = $self->{movie} unless defined $self->{name}; |
297
|
0
|
|
|
|
|
|
delete $self->{movie}; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# Process Series/Movie |
301
|
0
|
|
|
|
|
|
for my $key (qw(name movie epname title)) { |
302
|
0
|
0
|
|
|
|
|
if (defined $self->{$key}) { |
303
|
0
|
0
|
|
|
|
|
if ($self->{$key} =~ /^.*\/(.*?)$/) { |
304
|
|
|
|
|
|
|
# Get rid of any directory parts |
305
|
0
|
|
|
|
|
|
$self->{"guess-$key"} = $self->{$key}; |
306
|
|
|
|
|
|
|
# Keep the original name without '/' just in case the name contains a subdir |
307
|
0
|
|
|
|
|
|
$self->{$key} = $1; |
308
|
0
|
|
|
|
|
|
$self->{"guess-$key"} =~ s/[\/\s._-]+/ /; |
309
|
|
|
|
|
|
|
} |
310
|
0
|
0
|
|
|
|
|
$self->{$key} =~ s/[$self->{spaces}]+/ /g if defined $self->{spaces}; |
311
|
0
|
|
|
|
|
|
$self->{$key} =~ s/^\s*(.+?)\s*$/$1/; # Remove leading/trailing separators |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
# Guess part from epname |
316
|
0
|
0
|
0
|
|
|
|
if (defined $self->{epname} && !defined $self->{part}) { |
317
|
0
|
|
|
|
|
|
my $rmpart = 'Episode|Part|PT'; # Remove "Part #" from episode name |
318
|
0
|
|
|
|
|
|
my $epname = &_allnum2int($self->{epname}); # Make letters into integers |
319
|
0
|
0
|
0
|
|
|
|
if ($epname =~ /(?:$rmpart) (\d+)/i |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
320
|
|
|
|
|
|
|
|| $epname =~ /(\d+)\s*(?:of|-)\s*\d+/i |
321
|
|
|
|
|
|
|
|| $epname =~ /^(\d+)/ |
322
|
|
|
|
|
|
|
|| $epname =~ /[\s._-](\d+)$/ |
323
|
|
|
|
|
|
|
) { |
324
|
0
|
|
|
|
|
|
$self->{part} = $1; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# Cosmetics |
329
|
0
|
|
|
|
|
|
for my $key (qw(dvd season episode endep part)) { |
330
|
0
|
0
|
|
|
|
|
$self->{$key} =~ s/^0+// if defined $self->{$key}; |
331
|
|
|
|
|
|
|
} |
332
|
0
|
0
|
|
|
|
|
$self->{endep} = undef if $self->{endep} == $self->{episode}; |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
# Convenience for some developpers |
335
|
0
|
0
|
|
|
|
|
if (defined $self->{season}) { |
|
|
0
|
|
|
|
|
|
336
|
0
|
|
|
|
|
|
$self->{seasonepisode} = sprintf("S%02dE%02d", $self->{season}, $self->{episode}); |
337
|
|
|
|
|
|
|
} elsif (defined $self->{dvd}) { |
338
|
0
|
|
|
|
|
|
$self->{seasonepisode} = sprintf("D%02dE%02.1f", $self->{dvd}, $self->{episode}); |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
|
&debug(2, '', VideoFilename=>$self); |
342
|
0
|
|
|
|
|
|
return $self; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
############################################################################### |
346
|
|
|
|
|
|
|
sub _num2int { |
347
|
0
|
|
|
0
|
|
|
my $str = shift; |
348
|
0
|
|
|
|
|
|
my ($n, $c, $sum) = (0, 0, 0); |
349
|
0
|
|
|
|
|
|
while ($str) { |
350
|
0
|
|
|
|
|
|
$str =~ s/^[\s,]+//; |
351
|
0
|
|
|
|
|
|
debug(3, "STR=$str NUM=$n\n"); |
352
|
|
|
|
|
|
|
|
353
|
0
|
0
|
|
|
|
|
if ($str =~ s/^(zero|and|&)//i) { next; |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
354
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^one//i) { $n += 1; |
355
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^tw(o|en)//i) { $n += 2; |
356
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^th(ree|ir)//i) { $n += 3; |
357
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^four//i) { $n += 4; |
358
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^fi(ve|f)//i) { $n += 5; |
359
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^six//i) { $n += 6; |
360
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^seven//i) { $n += 7; |
361
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^eight//i) { $n += 8; |
362
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^nine//i) { $n += 9; |
363
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^(t|te|e)en//i) { $n += 10; |
364
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^eleven//i) { $n += 11; |
365
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^twelve//i) { $n += 12; |
366
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^t?y//i) { $n *= 10; |
367
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^hundred//i) { $c += $n * 100; $n = 0; |
|
0
|
|
|
|
|
|
|
368
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^thousand//i) { $sum += ($c+$n) * 1000; ($c,$n) = (0,0); |
|
0
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^million//i) { $sum += ($c+$n) * 1000000; ($c,$n) = (0,0); |
|
0
|
|
|
|
|
|
|
370
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^billion//i) { $sum += ($c+$n) * 1000000000; ($c,$n) = (0,0); |
|
0
|
|
|
|
|
|
|
371
|
0
|
|
|
|
|
|
} elsif ($str =~ s/^trillion//i) { $sum += ($c+$n) * 1000000000000; ($c,$n) = (0,0); |
|
0
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
} |
374
|
0
|
|
|
|
|
|
$sum += ($c+$n); |
375
|
0
|
|
|
|
|
|
debug(2, "STR=$str SUM=$sum\n"); |
376
|
0
|
|
|
|
|
|
return $sum; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
sub _allnum2int { |
379
|
0
|
|
|
0
|
|
|
my ($str, $prefix, $end) = @_; |
380
|
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
|
my $single = 'zero|one|two|three|five|(?:twen|thir|four|fif|six|seven|nine)(?:|teen|ty)|eight(?:|een|y)|ten|eleven|twelve'; |
382
|
0
|
|
|
|
|
|
my $mult = 'hundred|thousand|(?:m|b|tr)illion'; |
383
|
0
|
|
|
|
|
|
my $regex = "((?:(?:$single|$mult)(?:$single|$mult|\s|,|and|&)+)?(?:$single|$mult))"; |
384
|
|
|
|
|
|
|
|
385
|
0
|
0
|
|
|
|
|
if ($] >= 5.010000) { |
386
|
0
|
|
|
|
|
|
$str =~ s/$prefix\K\b$regex\b/&_num2int($1)/egis; |
|
0
|
|
|
|
|
|
|
387
|
0
|
0
|
|
|
|
|
$str =~ s/$end\K\b$regex$/&_num2int($1)/egis if defined $end; |
|
0
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
} else { |
389
|
0
|
|
|
|
|
|
$str =~ s/($prefix)\b$regex\b/"$1".&_num2int($2)/egis; |
|
0
|
|
|
|
|
|
|
390
|
0
|
0
|
|
|
|
|
$str =~ s/($end)\b$regex$/"$1".&_num2int($2)/egis if defined $end; |
|
0
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
|
return $str; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
sub _allroman2int { |
396
|
0
|
|
|
0
|
|
|
my ($str, $prefix, $end) = @_; |
397
|
|
|
|
|
|
|
|
398
|
0
|
|
|
|
|
|
my $roman = '[MC]*[DC]*[CX]*[LX]*[XI]*[VI]*'; |
399
|
0
|
0
|
|
|
|
|
if ($] >= 5.010000) { |
400
|
0
|
|
|
|
|
|
$str =~ s/\b$prefix\K($roman)\b/roman2int($1)/egi; |
|
0
|
|
|
|
|
|
|
401
|
0
|
0
|
|
|
|
|
$str =~ s/\b$end\K($roman)$/roman2int($1)/egi if defined $end; |
|
0
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
} else { |
403
|
0
|
|
|
|
|
|
$str =~ s/\b($prefix)($roman)\b/"$1".roman2int($2)/egi; |
|
0
|
|
|
|
|
|
|
404
|
0
|
0
|
|
|
|
|
$str =~ s/\b($end)($roman)$/"$1".roman2int($2)/egi if defined $end; |
|
0
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
} |
406
|
0
|
|
|
|
|
|
return $str; |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
############################################################################### |
410
|
|
|
|
|
|
|
sub isDVDshow { |
411
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
412
|
0
|
|
0
|
|
|
|
return defined $self->{dvd} && defined $self->{episode}; |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
############################################################################### |
416
|
|
|
|
|
|
|
sub isTVshow { |
417
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
418
|
0
|
|
0
|
|
|
|
return defined $self->{season} && defined $self->{episode}; |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
############################################################################### |
422
|
|
|
|
|
|
|
sub isEpisode { |
423
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
424
|
0
|
|
|
|
|
|
return defined $self->{episode}; |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
############################################################################### |
428
|
|
|
|
|
|
|
sub isMovie { |
429
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
430
|
0
|
|
0
|
|
|
|
return defined $self->{movie} || defined $self->{imdb}; |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
############################################################################### |
434
|
|
|
|
|
|
|
sub testVideoFilename { |
435
|
0
|
|
|
0
|
1
|
|
my @funcs = qw(isDVDshow isTVshow isEpisode isMovie); |
436
|
0
|
|
|
|
|
|
for my $pat (@filePatterns) { |
437
|
0
|
|
|
|
|
|
for my $test (@{$pat->{test_files}}) { |
|
0
|
|
|
|
|
|
|
438
|
0
|
|
|
|
|
|
my $file = new($test->[0]); |
439
|
|
|
|
|
|
|
# Make the correct rule fired |
440
|
0
|
0
|
|
|
|
|
if ($file->{regex} ne $pat->{re}) { |
441
|
0
|
|
|
|
|
|
print RED "PATT RE: $pat->{re}\nFILE RE: $file->{regex}\n"; |
442
|
0
|
|
|
|
|
|
print RED "FAILED: $file->{file} (wrong rule)\n"; |
443
|
0
|
|
|
|
|
|
print Dumper($file); exit; |
|
0
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
# Make sure all the attributes were correctly parsed |
446
|
0
|
|
|
|
|
|
my $keys = $pat->{test_keys}; |
447
|
0
|
|
|
|
|
|
for my $i (1..8) { |
448
|
0
|
|
|
|
|
|
my $attr = $file->{$keys->[$i]}; |
449
|
0
|
|
|
|
|
|
my $value = $test->[$i]; |
450
|
0
|
0
|
|
|
|
|
if ($attr ne $value) { |
451
|
0
|
|
|
|
|
|
print RED "'$attr' ne '$value'\nFAILED: $file->{file}\n"; |
452
|
0
|
|
|
|
|
|
print Dumper($file); exit; |
|
0
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
} |
454
|
0
|
|
|
|
|
|
&verbose(1, "'$attr' eq '$value'\n"); |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
# Make sure all the isXXXX() functions work properly |
457
|
0
|
|
|
|
|
|
for my $i (0..$#funcs) { |
458
|
0
|
0
|
|
|
|
|
unless (eval "\$file->$funcs[$i]()" == $pat->{test_funcs}->[$i]) { |
459
|
0
|
|
|
|
|
|
print RED "\$file->$funcs[$i]() != $pat->{test_funcs}->[$i]\nFAILED: $file->{file}\n"; |
460
|
0
|
|
|
|
|
|
print Dumper($file); exit; |
|
0
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
} |
463
|
0
|
|
|
|
|
|
print GREEN "PASSED: $file->{file}\n"; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
############################################################################### |
469
|
|
|
|
|
|
|
__END__ |