forked from z411/trackma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_anime_info_extractor.py
285 lines (240 loc) · 7.21 KB
/
test_anime_info_extractor.py
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
from pprint import pprint
from trackma.extras import AnimeInfoExtractor
DEFAULTS = {
'resolution': '',
'hash': '',
'subberTag': '',
'videoType': [],
'audioType': [],
'releaseSource': [],
'extension': '',
'episodeStart': None,
'episodeEnd': None,
'volumeStart': None,
'volumeEnd': None,
'version': 1,
'name': '',
'pv': -1,
'season': None,
}
def _assert_aie(filename, **assertions):
"""Helper for asserting AnimeInfoExtractor results.
Accepts a dict of assertions and asserts everything not provided as unchanged.
"""
aie = AnimeInfoExtractor(filename)
pprint(vars(aie)) # print details for quicker debugging on failure
for key, default in DEFAULTS.items():
expected = assertions.get(key, default)
assert getattr(aie, key) == expected
return aie
def test_horriblesubs():
filename = "[HorribleSubs] Nobunaga-sensei no Osanazuma - 04 [720p].mkv"
aie = _assert_aie(
filename,
name="Nobunaga-sensei no Osanazuma",
episodeStart=4,
subberTag="HorribleSubs",
extension="mkv",
resolution="720p",
)
# check these only once
assert aie.originalFilename == filename
assert aie.getName() == "Nobunaga-sensei no Osanazuma"
assert aie.getEpisode() == 4
def test_compound_subber_tag_and_wierd_epnum():
_assert_aie(
"[VCB-Studio+Commie] Sword Art Online II [03].mkv",
name="Sword Art Online II",
episodeStart=3,
subberTag="VCB-Studio+Commie",
extension="mkv",
)
def test_late_subber_tag_with_hash_and_commas():
_assert_aie(
"Chio-chan no Tsuugakuro - 04 [HorribleSubs] [www, 720p, AAC] [5D4D1205].mkv",
name="Chio-chan no Tsuugakuro",
episodeStart=4,
subberTag="HorribleSubs",
extension="mkv",
resolution="720p",
audioType=["AAC"],
hash="5D4D1205",
releaseSource=["www"],
)
def test_dubsub():
_assert_aie(
"Arifureta E01v1 [1080p+][AAC][JapDub][GerSub][Web-DL].mkv",
name="Arifureta",
episodeStart=1,
subberTag="JapDub",
extension="mkv",
resolution="1080p",
audioType=["AAC"],
releaseSource=["Web-DL"],
)
def test_name_with_year():
_assert_aie(
"[TestTag] Bungou Stray Dogs (2019) - 06 [496D45BB].mkv",
name="Bungou Stray Dogs (2019)",
episodeStart=6,
subberTag="TestTag",
extension="mkv",
hash="496D45BB",
)
def test_name_with_year_and_extra_brackets():
_assert_aie(
"[Erai-raws] Fairy Tail (2018) - 45 [1080p][Multiple Subtitle].mkv",
name="Fairy Tail (2018)",
episodeStart=45,
subberTag="Erai-raws",
extension="mkv",
resolution="1080p",
)
def test_eac3():
_assert_aie(
"[PAS] Houseki no Kuni - 05 [WEB 720p E-AC-3] [F671AE53].mkv",
name="Houseki no Kuni",
episodeStart=5,
subberTag="PAS",
extension="mkv",
resolution="720p",
audioType=["E-AC-3"],
releaseSource=["WEB"],
hash="F671AE53",
)
def test_with_number_in_episode_title():
_assert_aie(
"[Opportunity] The Tatami Galaxy 10 - The 4.5-Tatami Idealogue [BD 720p] [FF757616].mkv",
name="The Tatami Galaxy",
episodeStart=10,
subberTag="Opportunity",
extension="mkv",
resolution="720p",
releaseSource=["BD"],
hash="FF757616",
)
def test_with_standalone_number_in_episode_title():
_assert_aie(
"Monogatari - S02E01 - Karen Bee - Part 2.mkv",
name="Monogatari 2",
season=2,
episodeStart=1,
extension="mkv",
)
def test_sXXeXX_and_sdtv():
_assert_aie(
"Clannad - S02E01 - A Farewell to the End of Summer SDTV.mkv",
name="Clannad 2",
season=2,
episodeStart=1,
extension="mkv",
resolution="SD",
releaseSource=["TV"],
)
def test_sXXeXX_and_trailing_hyphen():
_assert_aie(
"ReZERO -Starting Life in Another World- S02E06 [1080p][E-AC3].mkv",
name="ReZERO -Starting Life in Another World- 2",
season=2,
episodeStart=6,
extension="mkv",
resolution="1080p",
audioType=["E-AC3"],
)
def test_with_brackets():
_assert_aie(
"[HorribleSubs] Nakanohito Genome [Jikkyouchuu] - 01 [1080p].mkv",
name="Nakanohito Genome", # ' [Jikkyouchuu]' is stripped currently
episodeStart=1,
subberTag="HorribleSubs",
extension="mkv",
resolution="1080p",
)
def test_with_dots():
_assert_aie(
"Kill.la.Kill.S01E01.1080p-Hi10p.BluRay.FLAC2.0.x264-CTR.[98AA9B1C].mkv",
name="Kill la Kill",
season=1,
episodeStart=1,
extension="mkv",
resolution="1080p",
# releaseSource=["BluRay"],
# audioType=["FLAC"],
videoType=["H264", "Hi10P"],
hash="98AA9B1C",
)
def test_unusual_subber():
_assert_aie(
"[-__-'] Girls und Panzer OVA 6 [BD 1080p FLAC] [B13C83A0].mkv",
name="Girls und Panzer OVA",
episodeStart=6,
subberTag="-__-'",
extension="mkv",
resolution="1080p",
releaseSource=["BD"],
audioType=["FLAC"],
hash="B13C83A0",
)
def test_unusual_subber_and_no_epnum():
_assert_aie(
"[-__-'] Girls und Panzer OVA Anzio-sen [BD 1080p FLAC] [231FDA45].mkv",
name="Girls und Panzer OVA Anzio-sen",
subberTag="-__-'",
extension="mkv",
resolution="1080p",
releaseSource=["BD"],
audioType=["FLAC"],
hash="231FDA45",
)
def test_nothing_in_particular():
_assert_aie(
"[Underwater-FFF] Saki Zenkoku-hen - The Nationals - 01 [BD][1080p-FLAC][81722FD7].mkv",
name="Saki Zenkoku-hen - The Nationals",
episodeStart=1,
subberTag="Underwater-FFF",
extension="mkv",
resolution="1080p",
releaseSource=["BD"],
audioType=["FLAC"],
hash="81722FD7",
)
def test_hi444pp_profile():
_assert_aie(
"[Erai-raws] Goblin Slayer - Goblin's Crown [BD][1080p YUV444P10][FLAC][Multiple Subtitle].mkv",
name="Goblin Slayer - Goblin's Crown",
subberTag="Erai-raws",
extension="mkv",
resolution="1080p",
releaseSource=["BD"],
audioType=["FLAC"],
videoType=["H264", "Hi444PP"],
)
def test_jpbd_lpcm():
_assert_aie(
"[Koten_Gars] Kiddy Grade - Movie I [JP.BD][Hi10][1080p][LPCM] [2FAAB41B].mkv",
name="Kiddy Grade - Movie I",
subberTag="Koten_Gars",
extension="mkv",
resolution="1080p",
releaseSource=["BD"],
audioType=["LPCM"],
videoType=["H264", "Hi10P"],
hash="2FAAB41B"
)
def test_underscores():
_assert_aie(
"[No]Touhou_Gensou_Mangekyou_-_01_(Hi10P)[26D7A2B3].mkv",
name="Touhou Gensou Mangekyou",
episodeStart=1,
subberTag="No",
extension="mkv",
videoType=["H264", "Hi10P"],
hash="26D7A2B3"
)
def test_literal_ep():
_assert_aie(
"Uzaki-chan wa Asobitai! Ep 2.mkv",
name="Uzaki-chan wa Asobitai!",
episodeStart=2,
extension="mkv",
)